summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-15 15:26:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-15 15:26:12 +0000
commit7da059bddbc3b230eef74ada37ee8ddc60ece9e4 (patch)
treef2cfe16b354936c2ebcc816ee8eab8707a020958 /bignum.c
parent26b5fd1e7b083ae3e9b81eb2f78225d5fdf484d2 (diff)
* bignum.c (rb_big_pow): removed invariant variable. [ruby-dev:31236]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/bignum.c b/bignum.c
index 788db18dd1..5763e8c72f 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1754,7 +1754,7 @@ rb_big_pow(x, y)
yy = FIX2LONG(y);
if (yy > 0) {
VALUE z = 0;
- long mask, n = 1;
+ long mask;
if (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) {
rb_warn("in a**b, b may be too big");
@@ -1762,21 +1762,9 @@ rb_big_pow(x, y)
break;
}
for (mask = FIXNUM_MAX + 1; mask; mask >>= 1) {
- if (!z) {
- long 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);