diff options
Diffstat (limited to 'ledger.cc')
-rw-r--r-- | ledger.cc | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -96,12 +96,16 @@ bool entry::matches(const std::list<mask>& regexps) const } } +#ifdef DO_CLEANUP + totals::~totals() { for (iterator i = amounts.begin(); i != amounts.end(); i++) delete (*i).second; } +#endif // DO_CLEANUP + void totals::credit(const totals& other) { for (const_iterator i = other.amounts.begin(); @@ -236,9 +240,10 @@ bool matches(const std::list<mask>& regexps, const std::string& str, return match; } +#ifdef DO_CLEANUP + state::~state() { -#if 0 for (commodities_iterator i = commodities.begin(); i != commodities.end(); i++) @@ -253,9 +258,10 @@ state::~state() i != entries.end(); i++) delete *i; -#endif } +#endif // DO_CLEANUP + void state::record_price(const char * setting) { char buf[128]; @@ -275,6 +281,10 @@ void state::record_price(const char * setting) account * state::find_account(const char * name, bool create) { + accounts_iterator i = accounts_cache.find(name); + if (i != accounts_cache.end()) + return (*i).second; + char * buf = new char[std::strlen(name) + 1]; std::strcpy(buf, name); @@ -307,6 +317,9 @@ account * state::find_account(const char * name, bool create) delete[] buf; + if (current) + accounts_cache.insert(accounts_entry(name, current)); + return current; } |