Avoid unnecessary object copying when using foreach
This commit is contained in:
parent
c3cc935ba6
commit
27b86a5388
4 changed files with 7 additions and 7 deletions
|
|
@ -262,7 +262,7 @@ commodity_t::varied_history_t::find_price(const commodity_t& source,
|
||||||
price_point_t best;
|
price_point_t best;
|
||||||
bool found = false;
|
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);
|
commodity_t& comm(*hist.first);
|
||||||
if (comm == source)
|
if (comm == source)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ void post_splitter::print_title(const value_t& val)
|
||||||
|
|
||||||
void post_splitter::flush()
|
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);
|
preflush_func(pair.first);
|
||||||
|
|
||||||
foreach (post_t * post, pair.second)
|
foreach (post_t * post, pair.second)
|
||||||
|
|
@ -894,7 +894,7 @@ void posts_as_equity::report_subtotal()
|
||||||
value_t total = 0L;
|
value_t total = 0L;
|
||||||
foreach (values_map::value_type& pair, values) {
|
foreach (values_map::value_type& pair, values) {
|
||||||
if (pair.second.value.is_balance()) {
|
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)
|
pair.second.value.as_balance().amounts)
|
||||||
handle_value(amount_pair.second, pair.second.account, &xact, temps,
|
handle_value(amount_pair.second, pair.second.account, &xact, temps,
|
||||||
handler);
|
handler);
|
||||||
|
|
@ -907,7 +907,7 @@ void posts_as_equity::report_subtotal()
|
||||||
values.clear();
|
values.clear();
|
||||||
|
|
||||||
if (total.is_balance()) {
|
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) {
|
total.as_balance().amounts) {
|
||||||
post_t& balance_post = temps.create_post(xact, balance_account);
|
post_t& balance_post = temps.create_post(xact, balance_account);
|
||||||
balance_post.amount = - pair.second;
|
balance_post.amount = - pair.second;
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,9 @@ void posts_commodities_iterator::reset(journal_t& journal)
|
||||||
comm->varied_history()) {
|
comm->varied_history()) {
|
||||||
account_t * account = journal.master->find_account(comm->symbol());
|
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) {
|
history->histories) {
|
||||||
foreach (commodity_t::history_map::value_type hpair,
|
foreach (commodity_t::history_map::value_type& hpair,
|
||||||
pair.second.prices) {
|
pair.second.prices) {
|
||||||
xact_t * xact;
|
xact_t * xact;
|
||||||
string symbol = hpair.second.commodity().symbol();
|
string symbol = hpair.second.commodity().symbol();
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ public:
|
||||||
|
|
||||||
virtual ~commodity_pool_t() {
|
virtual ~commodity_pool_t() {
|
||||||
TRACE_DTOR(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);
|
checked_delete(pair.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue