mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
numeric.c: short circuit
* numeric.c (int_pow): short circuit when y is 0, always return 1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7ccae4d150
commit
f0f8234a26
1 changed files with 1 additions and 0 deletions
|
@ -3892,6 +3892,7 @@ int_pow(long x, unsigned long y)
|
|||
int neg = x < 0;
|
||||
long z = 1;
|
||||
|
||||
if (y == 0) return INT2FIX(1);
|
||||
if (neg) x = -x;
|
||||
if (y & 1)
|
||||
z = x;
|
||||
|
|
Loading…
Add table
Reference in a new issue