diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-03 17:43:38 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-03 17:43:38 -0400 |
commit | 27b86a5388a9b1a5d5c748fa7e6f8aa4a2f1a3f4 (patch) | |
tree | d4d4d279d70a03d8e8a0d5b39afeb34c88e87d70 | |
parent | c3cc935ba6f22f580518fd8858fbe424f2842f31 (diff) | |
download | fork-ledger-27b86a5388a9b1a5d5c748fa7e6f8aa4a2f1a3f4.tar.gz fork-ledger-27b86a5388a9b1a5d5c748fa7e6f8aa4a2f1a3f4.tar.bz2 fork-ledger-27b86a5388a9b1a5d5c748fa7e6f8aa4a2f1a3f4.zip |
Avoid unnecessary object copying when using foreach
-rw-r--r-- | src/commodity.cc | 2 | ||||
-rw-r--r-- | src/filters.cc | 6 | ||||
-rw-r--r-- | src/iterators.cc | 4 | ||||
-rw-r--r-- | src/pool.h | 2 |
4 files changed, 7 insertions, 7 deletions
diff --git a/src/commodity.cc b/src/commodity.cc index 1b85910f..a1c26403 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -262,7 +262,7 @@ commodity_t::varied_history_t::find_price(const commodity_t& source, price_point_t best; bool found = false; - foreach (history_by_commodity_map::value_type hist, histories) { + foreach (const history_by_commodity_map::value_type& hist, histories) { commodity_t& comm(*hist.first); if (comm == source) continue; diff --git a/src/filters.cc b/src/filters.cc index ad4b88a0..70a46e8e 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -50,7 +50,7 @@ void post_splitter::print_title(const value_t& val) void post_splitter::flush() { - foreach (value_to_posts_map::value_type pair, posts_map) { + foreach (value_to_posts_map::value_type& pair, posts_map) { preflush_func(pair.first); foreach (post_t * post, pair.second) @@ -894,7 +894,7 @@ void posts_as_equity::report_subtotal() value_t total = 0L; foreach (values_map::value_type& pair, values) { if (pair.second.value.is_balance()) { - foreach (balance_t::amounts_map::value_type amount_pair, + foreach (const balance_t::amounts_map::value_type& amount_pair, pair.second.value.as_balance().amounts) handle_value(amount_pair.second, pair.second.account, &xact, temps, handler); @@ -907,7 +907,7 @@ void posts_as_equity::report_subtotal() values.clear(); if (total.is_balance()) { - foreach (balance_t::amounts_map::value_type pair, + foreach (const balance_t::amounts_map::value_type& pair, total.as_balance().amounts) { post_t& balance_post = temps.create_post(xact, balance_account); balance_post.amount = - pair.second; diff --git a/src/iterators.cc b/src/iterators.cc index f3a68978..ade1d4b3 100644 --- a/src/iterators.cc +++ b/src/iterators.cc @@ -94,9 +94,9 @@ void posts_commodities_iterator::reset(journal_t& journal) comm->varied_history()) { account_t * account = journal.master->find_account(comm->symbol()); - foreach (commodity_t::history_by_commodity_map::value_type pair, + foreach (commodity_t::history_by_commodity_map::value_type& pair, history->histories) { - foreach (commodity_t::history_map::value_type hpair, + foreach (commodity_t::history_map::value_type& hpair, pair.second.prices) { xact_t * xact; string symbol = hpair.second.commodity().symbol(); @@ -86,7 +86,7 @@ public: virtual ~commodity_pool_t() { TRACE_DTOR(commodity_pool_t); - foreach (commodities_map::value_type pair, commodities) + foreach (commodities_map::value_type& pair, commodities) checked_delete(pair.second); } |