diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-15 15:26:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-15 15:26:12 +0000 |
commit | 91594a2c3a57e6c5a83733e74927a06c45a0d689 (patch) | |
tree | 1e92b6b2c409098ace98edcbbf3a425fc2f6fc79 /bignum.c | |
parent | 8ad9dbb28179a21a4ae8a015b2a56b425a99c2da (diff) | |
download | ruby-91594a2c3a57e6c5a83733e74927a06c45a0d689.tar.gz ruby-91594a2c3a57e6c5a83733e74927a06c45a0d689.tar.xz ruby-91594a2c3a57e6c5a83733e74927a06c45a0d689.zip |
* bignum.c (rb_big_pow): removed invariant variable. [ruby-dev:31236]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 18 |
1 files changed, 3 insertions, 15 deletions
@@ -1674,7 +1674,7 @@ rb_big_pow(VALUE x, VALUE y) yy = FIX2LONG(y); if (yy > 0) { VALUE z = 0; - SIGNED_VALUE mask, n = 1; + SIGNED_VALUE mask; if (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) { rb_warn("in a**b, b may be too big"); @@ -1682,21 +1682,9 @@ rb_big_pow(VALUE x, VALUE y) break; } for (mask = FIXNUM_MAX + 1; mask; mask >>= 1) { - if (!z) { - SIGNED_VALUE n2 = n * n; - if (!POSFIXABLE(n2) || (n2 / n != n)) { - z = bigtrunc(bigsqr(rb_int2big(n))); - } - else { - n = n2; - } - } - else { - z = bigtrunc(bigsqr(z)); - } + if (z) z = bigtrunc(bigsqr(z)); if (yy & mask) { - if (!z) z = rb_int2big(n); - z = bigtrunc(rb_big_mul0(z, x)); + z = z ? bigtrunc(rb_big_mul0(z, x)) : x; } } return bignorm(z); |