[Python-checkins] cpython: Issue #27786: Simplify x_sub()

victor.stinner python-checkins at python.org
Wed Aug 17 13:49:01 EDT 2016


https://hg.python.org/cpython/rev/be9dc240bf28
changeset:   102736:be9dc240bf28
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Aug 17 19:48:33 2016 +0200
summary:
  Issue #27786: Simplify x_sub()

The z variable is known to be a fresh number which cannot be shared, Py_SIZE()
can be used directly to negate the number.

files:
  Objects/longobject.c |  4 +---
  1 files changed, 1 insertions(+), 3 deletions(-)


diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -3000,9 +3000,7 @@
     }
     assert(borrow == 0);
     if (sign < 0) {
-        _PyLong_Negate(&z);
-        if (z == NULL)
-            return NULL;
+        Py_SIZE(z) = -Py_SIZE(z);
     }
     return long_normalize(z);
 }

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


More information about the Python-checkins mailing list