[pypy-svn] pypy default: Try to reduce the number of copies rbigint does, the _normalize call is not necessary because both _x_{add, sub} call it already.

alex_gaynor commits-noreply at bitbucket.org
Mon Jan 10 06:30:16 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r40546:48bb1391d70c
Date: 2011-01-09 23:28 -0600
http://bitbucket.org/pypy/pypy/changeset/48bb1391d70c/

Log:	Try to reduce the number of copies rbigint does, the _normalize call
	is not necessary because both _x_{add,sub} call it already.

diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -294,7 +294,6 @@
         else:
             result = _x_sub(other, self)
         result.sign *= other.sign
-        result._normalize()
         return result
 
     def sub(self, other):
@@ -554,7 +553,8 @@
         while i > 1 and self.digits[i - 1] == 0:
             i -= 1
         assert i >= 1
-        self.digits = self.digits[:i]
+        if i != self._numdigits():
+            self.digits = self.digits[:i]
         if self._numdigits() == 1 and self.digits[0] == 0:
             self.sign = 0
 


More information about the Pypy-commit mailing list