]> granicus.if.org Git - python/commitdiff
Issue #27786: Simplify x_sub()
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 17 Aug 2016 17:48:33 +0000 (19:48 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 17 Aug 2016 17:48:33 +0000 (19:48 +0200)
The z variable is known to be a fresh number which cannot be shared, Py_SIZE()
can be used directly to negate the number.

Objects/longobject.c

index d49594d129230290221ec594a5c9d4f47e4cd98b..4b2b6021a9c10bc5f6a1f129f156d45dc5ce49b6 100644 (file)
@@ -3000,9 +3000,7 @@ x_sub(PyLongObject *a, PyLongObject *b)
     }
     assert(borrow == 0);
     if (sign < 0) {
-        _PyLong_Negate(&z);
-        if (z == NULL)
-            return NULL;
+        Py_SIZE(z) = -Py_SIZE(z);
     }
     return long_normalize(z);
 }