diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-05 07:27:19 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-05 07:27:19 +0000 |
commit | 194ff269493be5df0248ebf4cb50412ed8a01c3a (patch) | |
tree | 423a6871548455e5cb0fb400e7167b4065b55089 | |
parent | f2f94c95a24b88cba856258e21dd1ab6fd57fc07 (diff) | |
download | ruby-194ff269493be5df0248ebf4cb50412ed8a01c3a.tar.gz |
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
-rw-r--r-- | numeric.c | 1 |
1 files changed, 1 insertions, 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; |