Made amount_t::is_zero() slightly more efficient.

This commit is contained in:
John Wiegley 2009-01-31 05:00:49 -04:00
parent cce65b8dd2
commit ec6a3e8081

View file

@ -625,7 +625,18 @@ bool amount_t::is_zero() const
if (has_commodity()) {
if (keep_precision() || quantity->prec <= commodity().precision()) {
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;
stream_out_mpq(out, MP(quantity), commodity().precision());