[Python-checkins] cpython: Add one extra comparison to the _mpd_shortmul() case to avoid repetitive code.

stefan.krah python-checkins at python.org
Sat Jun 9 15:30:31 CEST 2012


http://hg.python.org/cpython/rev/08c474d33f82
changeset:   77392:08c474d33f82
user:        Stefan Krah <skrah at bytereef.org>
date:        Sat Jun 09 15:28:36 2012 +0200
summary:
  Add one extra comparison to the _mpd_shortmul() case to avoid repetitive code.

files:
  Modules/_decimal/libmpdec/mpdecimal.c |  26 +++++---------
  1 files changed, 9 insertions(+), 17 deletions(-)


diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c
--- a/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/Modules/_decimal/libmpdec/mpdecimal.c
@@ -5543,32 +5543,24 @@
 
 
     if (small->len == 1) {
-        if ((rdata = mpd_calloc(rsize, sizeof *rdata)) == NULL) {
-            mpd_seterror(result, MPD_Malloc_error, status);
-            return;
-        }
-        _mpd_shortmul(rdata, big->data, big->len, small->data[0]);
+        rdata = mpd_calloc(rsize, sizeof *rdata);
+        if (rdata != NULL) {
+            _mpd_shortmul(rdata, big->data, big->len, small->data[0]);
+        }
     }
     else if (rsize <= 1024) {
         rdata = _mpd_kmul(big->data, small->data, big->len, small->len, &rsize);
-        if (rdata == NULL) {
-            mpd_seterror(result, MPD_Malloc_error, status);
-            return;
-        }
     }
     else if (rsize <= 3*MPD_MAXTRANSFORM_2N) {
         rdata = _mpd_fntmul(big->data, small->data, big->len, small->len, &rsize);
-        if (rdata == NULL) {
-            mpd_seterror(result, MPD_Malloc_error, status);
-            return;
-        }
     }
     else {
         rdata = _mpd_kmul_fnt(big->data, small->data, big->len, small->len, &rsize);
-        if (rdata == NULL) {
-            mpd_seterror(result, MPD_Malloc_error, status); /* GCOV_UNLIKELY */
-            return; /* GCOV_UNLIKELY */
-        }
+    }
+
+    if (rdata == NULL) {
+        mpd_seterror(result, MPD_Malloc_error, status);
+        return;
     }
 
     if (mpd_isdynamic_data(result)) {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list