[pypy-commit] pypy math-improvements: Avoid copy if the sign stay the same in int_mul
stian
pypy.commits at gmail.com
Thu Oct 19 19:18:19 EDT 2017
Author: stian
Branch: math-improvements
Changeset: r92804:0f49fdf5b940
Date: 2017-10-19 23:03 +0200
http://bitbucket.org/pypy/pypy/changeset/0f49fdf5b940/
Log: Avoid copy if the sign stay the same in int_mul
diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py
--- a/rpython/rlib/rbigint.py
+++ b/rpython/rlib/rbigint.py
@@ -742,6 +742,8 @@
bsign = -1 if b < 0 else 1
if digit == 1:
+ if self.sign == bsign:
+ return self
return rbigint(self._digits[:self.numdigits()], self.sign * bsign, asize)
elif asize == 1:
res = self.widedigit(0) * digit
More information about the pypy-commit
mailing list