summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-01 14:34:59 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-01 14:34:59 +0000
commit69263bb7557de514f67bc5a8d27b91b4b781138a (patch)
treed5642ccd687fe6e43a842c5d3e4f71b99c2ffdcf
parent79be10475f0c8cc208ee8c5e220aba6cc5431687 (diff)
* bignum.c (rb_cstr_to_inum): Use power_cache_get_power.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c9
2 files changed, 9 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ab05bc9..40a89b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Aug 1 23:33:01 2013 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (rb_cstr_to_inum): Use power_cache_get_power.
+
Thu Aug 1 21:02:48 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (rb_big2str1): Raise an error for too big number.
diff --git a/bignum.c b/bignum.c
index 1bde7da..1f37209 100644
--- a/bignum.c
+++ b/bignum.c
@@ -141,6 +141,7 @@ static inline VALUE bigtrunc(VALUE x);
static VALUE bigsq(VALUE x);
static void bigdivmod(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp);
+static VALUE power_cache_get_power(int base, int power_level, size_t *numdigits_ret);
static int
nlz16(uint16_t x)
@@ -3833,13 +3834,12 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
BDIGIT_DBL dd;
BDIGIT_DBL current_base;
int m;
+ int power_level = 0;
uds = ALLOCV_N(BDIGIT, tmpuv, 2*num_bdigits);
vds = uds + num_bdigits;
- powerv = bignew(2, 1);
- BDIGITS(powerv)[0] = BIGLO(power);
- BDIGITS(powerv)[1] = (BDIGIT)BIGDN(power);
+ powerv = power_cache_get_power(base, power_level, NULL);
i = 0;
dd = 0;
@@ -3879,7 +3879,8 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
MEMCPY(vds+i, uds+i, BDIGIT, num_bdigits-i);
}
}
- powerv = bigtrunc(bigsq(powerv));
+ power_level++;
+ powerv = power_cache_get_power(base, power_level, NULL);
tds = vds;
vds = uds;
uds = tds;