Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch:
Changeset: r93763:864485a54ece
Date: 2018-02-05 12:27 +0100
http://bitbucket.org/pypy/pypy/changeset/864485a54ece/
Log: remove code duplication in floordiv
diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py
--- a/rpython/rlib/rbigint.py
+++ b/rpython/rlib/rbigint.py
@@ -762,12 +762,10 @@
@jit.elidable
def floordiv(self, other):
- if self.sign == 1 and other.numdigits() == 1 and other.sign == 1:
- digit = other.digit(0)
- if digit == 1:
- return rbigint(self._digits[:self.size], 1, self.size)
- elif digit and digit & (digit - 1) == 0:
- return self.rshift(ptwotable[digit])
+ if other.numdigits() == 1:
+ otherint = other.digit(0) * other.sign
+ assert int_in_valid_range(otherint)
+ return self.int_floordiv(otherint)
div, mod = _divrem(self, other)
if mod.sign * other.sign == -1:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit