Made amount_t::is_zero() slightly more efficient.
This commit is contained in:
parent
cce65b8dd2
commit
ec6a3e8081
1 changed files with 12 additions and 1 deletions
|
|
@ -625,7 +625,18 @@ bool amount_t::is_zero() const
|
||||||
if (has_commodity()) {
|
if (has_commodity()) {
|
||||||
if (keep_precision() || quantity->prec <= commodity().precision()) {
|
if (keep_precision() || quantity->prec <= commodity().precision()) {
|
||||||
return is_realzero();
|
return is_realzero();
|
||||||
} else {
|
}
|
||||||
|
else if (is_realzero()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (mpz_cmp(mpq_numref(MP(quantity)),
|
||||||
|
mpq_denref(MP(quantity))) > 0) {
|
||||||
|
DEBUG("amount.is_zero", "Numerator is larger than the denominator");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DEBUG("amount.is_zero", "We have to print the number to check for zero");
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
stream_out_mpq(out, MP(quantity), commodity().precision());
|
stream_out_mpq(out, MP(quantity), commodity().precision());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue