[前][次][番号順一覧][スレッド一覧]

ruby-changes:60463

From: Nobuyoshi <ko1@a...>
Date: Sat, 21 Mar 2020 16:49:35 +0900 (JST)
Subject: [ruby-changes:60463] 6f0446785b (master): Leave power cache table initialized as Qfalse

https://git.ruby-lang.org/ruby.git/commit/?id=6f0446785b

From 6f0446785b537994bceb9fc8574cdaa9b59cbef6 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 21 Mar 2020 16:42:19 +0900
Subject: Leave power cache table initialized as Qfalse


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]; https://github.com/ruby/ruby/blob/trunk/bignum.c#L4676
 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) https://github.com/ruby/ruby/blob/trunk/bignum.c#L4698
     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) https://github.com/ruby/ruby/blob/trunk/bignum.c#L4719
     }
     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 {
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]