diff options
author | Stefan Krah <skrah@bytereef.org> | 2012-06-11 06:57:17 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2012-06-11 06:57:17 (GMT) |
commit | 88e19779ad010a60c4b13fe0197a9a7a79af7587 (patch) | |
tree | b0ee5866e08904282d8c4bb55a09015936888619 | |
parent | a26ad5a0a177e308108867fa7dce06f1d55fa1af (diff) | |
download | cpython-88e19779ad010a60c4b13fe0197a9a7a79af7587.zip cpython-88e19779ad010a60c4b13fe0197a9a7a79af7587.tar.gz cpython-88e19779ad010a60c4b13fe0197a9a7a79af7587.tar.bz2 |
1) Replace long-winded abort() construct by assert().
2) Remove micro optimization (inline checking for NaN before calling
mpd_qcheck_nans()) that probably has no benefit in this case.
-rw-r--r-- | Modules/_decimal/libmpdec/mpdecimal.c | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c index f5be747..ff6d867 100644 --- a/Modules/_decimal/libmpdec/mpdecimal.c +++ b/Modules/_decimal/libmpdec/mpdecimal.c @@ -5713,30 +5713,28 @@ void mpd_qnext_minus(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx, uint32_t *status) { - mpd_context_t workctx; /* function context */ + mpd_context_t workctx; MPD_NEW_CONST(tiny,MPD_POS,mpd_etiny(ctx)-1,1,1,1,1); if (mpd_isspecial(a)) { if (mpd_qcheck_nan(result, a, ctx, status)) { return; } - if (mpd_isinfinite(a)) { - if (mpd_isnegative(a)) { - mpd_qcopy(result, a, status); - return; - } - else { - mpd_clear_flags(result); - mpd_qmaxcoeff(result, ctx, status); - if (mpd_isnan(result)) { - return; - } - result->exp = ctx->emax - ctx->prec + 1; + + assert(mpd_isinfinite(a)); + if (mpd_isnegative(a)) { + mpd_qcopy(result, a, status); + return; + } + else { + mpd_clear_flags(result); + mpd_qmaxcoeff(result, ctx, status); + if (mpd_isnan(result)) { return; } + result->exp = mpd_etop(ctx); + return; } - /* debug */ - abort(); /* GCOV_NOT_REACHED */ } mpd_workcontext(&workctx, ctx); @@ -5769,21 +5767,21 @@ mpd_qnext_plus(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx, if (mpd_qcheck_nan(result, a, ctx, status)) { return; } - if (mpd_isinfinite(a)) { - if (mpd_ispositive(a)) { - mpd_qcopy(result, a, status); - } - else { - mpd_clear_flags(result); - mpd_qmaxcoeff(result, ctx, status); - if (mpd_isnan(result)) { - return; - } - mpd_set_flags(result, MPD_NEG); - result->exp = mpd_etop(ctx); + + assert(mpd_isinfinite(a)); + if (mpd_ispositive(a)) { + mpd_qcopy(result, a, status); + } + else { + mpd_clear_flags(result); + mpd_qmaxcoeff(result, ctx, status); + if (mpd_isnan(result)) { + return; } - return; + mpd_set_flags(result, MPD_NEG); + result->exp = mpd_etop(ctx); } + return; } mpd_workcontext(&workctx, ctx); @@ -5814,9 +5812,8 @@ mpd_qnext_toward(mpd_t *result, const mpd_t *a, const mpd_t *b, { int c; - if (mpd_isnan(a) || mpd_isnan(b)) { - if (mpd_qcheck_nans(result, a, b, ctx, status)) - return; + if (mpd_qcheck_nans(result, a, b, ctx, status)) { + return; } c = _mpd_cmp(a, b); |