diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-21 23:18:45 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-21 23:18:45 -0400 |
commit | 6d5333b89618734e59853ba7da75b920ac40dae0 (patch) | |
tree | 3ddcc232a2c229a2ace5ca739ba7de3889fb6edc /valexpr.cc | |
parent | 3ff84b7363575c63129e5b7a5b142896b76dcf06 (diff) | |
download | fork-ledger-6d5333b89618734e59853ba7da75b920ac40dae0.tar.gz fork-ledger-6d5333b89618734e59853ba7da75b920ac40dae0.tar.bz2 fork-ledger-6d5333b89618734e59853ba7da75b920ac40dae0.zip |
use value_t instead of balance_pair_t; gains for 10% binary, 2% textual
Diffstat (limited to 'valexpr.cc')
-rw-r--r-- | valexpr.cc | 43 |
1 files changed, 19 insertions, 24 deletions
@@ -13,6 +13,8 @@ namespace ledger { mask_t::mask_t(const std::string& pat) : exclude(false) { + DEBUG_PRINT("ledger.memory.ctors", "ctor mask_t"); + const char * p = pat.c_str(); if (*p == '-') { exclude = true; @@ -40,6 +42,8 @@ mask_t::mask_t(const std::string& pat) : exclude(false) mask_t::mask_t(const mask_t& m) : exclude(m.exclude), pattern(m.pattern) { + DEBUG_PRINT("ledger.memory.ctors", "ctor mask_t"); + const char *error; int erroffset; regexp = pcre_compile(pattern.c_str(), PCRE_CASELESS, @@ -47,6 +51,11 @@ mask_t::mask_t(const mask_t& m) : exclude(m.exclude), pattern(m.pattern) assert(regexp); } +mask_t::~mask_t() { + DEBUG_PRINT("ledger.memory.dtors", "dtor mask_t"); + pcre_free((pcre *)regexp); +} + bool mask_t::match(const std::string& str) const { static int ovec[30]; @@ -55,10 +64,6 @@ bool mask_t::match(const std::string& str) const return result >= 0 && ! exclude; } -mask_t::~mask_t() { - pcre_free((pcre *)regexp); -} - void value_expr_t::compute(value_t& result, const details_t& details, value_t::type_t type) const @@ -79,7 +84,7 @@ void value_expr_t::compute(value_t& result, const details_t& details, if (details.xact) result = details.xact->amount; else if (details.account) - result = details.account->value.quantity; + result = details.account->value; break; case COST: @@ -90,32 +95,21 @@ void value_expr_t::compute(value_t& result, const details_t& details, result = details.xact->amount; } else if (details.account) { - if (details.account->value.cost) - result = *details.account->value.cost; - else - result = details.account->value.quantity; + result = details.account->value.cost(); } break; case TOTAL: if (details.xact) - result = details.xact->total.quantity; + result = details.xact->total; else if (details.account) - result = details.account->total.quantity; + result = details.account->total; break; case COST_TOTAL: - if (details.xact) { - if (details.xact->total.cost) - result = *details.xact->total.cost; - else - result = details.xact->total.quantity; - } - else if (details.account) { - if (details.account->total.cost) - result = *details.account->total.cost; - else - result = details.account->total.quantity; - } + if (details.xact) + result = details.xact->total.cost(); + else if (details.account) + result = details.account->total.cost(); break; case VALUE_EXPR: @@ -227,7 +221,8 @@ void value_expr_t::compute(value_t& result, const details_t& details, case F_STRIP: { assert(left); left->compute(result, details); - if (result.type == value_t::BALANCE) { + if (result.type == value_t::BALANCE || + result.type == value_t::BALANCE_PAIR) { // jww (2004-08-17): do something smarter here? result.cast(value_t::AMOUNT); } |