summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-03-21 16:42:19 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-03-21 16:42:19 +0900
commit6f0446785b537994bceb9fc8574cdaa9b59cbef6 (patch)
tree9f3a3e112fb9db3d85b18d2affb72624c8de88d0
parent318be1cb2f9c6f04403c063a5618c6267012ee51 (diff)
Leave power cache table initialized as Qfalse
-rw-r--r--bignum.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/bignum.c b/bignum.c
index 07b7cb2..8eea0a1 100644
--- a/bignum.c
+++ b/bignum.c
@@ -4676,12 +4676,6 @@ static size_t base36_numdigits_cache[35][MAX_BASE36_POWER_TABLE_ENTRIES];
static void
power_cache_init(void)
{
- int i, j;
- for (i = 0; i < 35; ++i) {
- for (j = 0; j < MAX_BASE36_POWER_TABLE_ENTRIES; ++j) {
- base36_power_cache[i][j] = Qnil;
- }
- }
}
static inline VALUE
@@ -4704,8 +4698,8 @@ power_cache_get_power(int base, int power_level, size_t *numdigits_ret)
if (MAX_BASE36_POWER_TABLE_ENTRIES <= power_level)
rb_bug("too big power number requested: maxpow_in_bdigit_dbl(%d)**(2**%d)", base, power_level);
- if (NIL_P(base36_power_cache[base - 2][power_level])) {
- VALUE power;
+ VALUE power = base36_power_cache[base - 2][power_level];
+ if (!power) {
size_t numdigits;
if (power_level == 0) {
int numdigits0;
@@ -4725,7 +4719,7 @@ power_cache_get_power(int base, int power_level, size_t *numdigits_ret)
}
if (numdigits_ret)
*numdigits_ret = base36_numdigits_cache[base - 2][power_level];
- return base36_power_cache[base - 2][power_level];
+ return power;
}
struct big2str_struct {