]> granicus.if.org Git - python/commitdiff
long_mul(): Simplified exit code. In particular, k_mul() returns a
authorTim Peters <tim.peters@gmail.com>
Thu, 15 Aug 2002 19:41:06 +0000 (19:41 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 15 Aug 2002 19:41:06 +0000 (19:41 +0000)
normalized result, so no point to normalizing it again.  The number
of test+branches was also excessive.

Objects/longobject.c

index 348dcc49dbd0abe6606018e990395899d6e52522..2343db81339d32eafe1db4ba9fc5b509091a8f4e 100644 (file)
@@ -1878,18 +1878,12 @@ long_mul(PyLongObject *v, PyLongObject *w)
        }
 
        z = k_mul(a, b);
-       if(z == NULL) {
-               Py_DECREF(a);
-               Py_DECREF(b);
-               return NULL;
-       }
-       if (a->ob_size < 0)
-               z->ob_size = -(z->ob_size);
-       if (b->ob_size < 0)
+       /* Negate if exactly one of the inputs is negative. */
+       if (((a->ob_size ^ b->ob_size) < 0) && z)
                z->ob_size = -(z->ob_size);
        Py_DECREF(a);
        Py_DECREF(b);
-       return (PyObject *) long_normalize(z);
+       return (PyObject *)z;
 }
 
 /* The / and % operators are now defined in terms of divmod().