From f0f8234a2635e4d63ebde8a3f9e8a3f70863379e Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 5 Jan 2017 07:27:19 +0000 Subject: 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 --- numeric.c | 1 + 1 file changed, 1 insertion(+) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index 28ad30d764..ee8c032eef 100644 --- a/numeric.c +++ b/numeric.c @@ -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; -- cgit v1.2.3