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 | f0f8234a2635e4d63ebde8a3f9e8a3f70863379e (patch) | |
tree | 423a6871548455e5cb0fb400e7167b4065b55089 /numeric.c | |
parent | 7ccae4d15034fab87af687c38038669f614c2d3b (diff) | |
download | bundler-f0f8234a2635e4d63ebde8a3f9e8a3f70863379e.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
Diffstat (limited to 'numeric.c')
-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; |