Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Small improvement to IntegerMulAction by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Mar 1, 2015
1 parent b5402b0 commit 1c074bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/sage/structure/coerce_actions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,20 @@ cdef inline fast_mul(a, n):

cdef inline fast_mul_long(a, long s):
# It's important to change the signed s to an unsigned n,
# see Trac #17844.
# since -LONG_MIN = LONG_MIN. See Trac #17844.
cdef unsigned long n
if s < 0:
n = -s
a = -a
else:
n = s
if n < 4:
if n == 0: return parent_c(a)(0)
if n == 0:
p = parent_c(a)
try:
return p.zero()
except AttributeError:
return p(0)
elif n == 1: return a
elif n == 2: return a+a
elif n == 3: return a+a+a
Expand Down

0 comments on commit 1c074bb

Please sign in to comment.