diff options
| author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-25 06:34:38 +0000 |
|---|---|---|
| committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-25 06:34:38 +0000 |
| commit | c60a0450734fba6463b1344df47179509705212d (patch) | |
| tree | d247f5ac3af7d52c14bc42f2e02b1205514b981a | |
| parent | 1112d50ac9632c2a67f4caea60b73a7eefc7b231 (diff) | |
| download | ruby-c60a0450734fba6463b1344df47179509705212d.tar.gz ruby-c60a0450734fba6463b1344df47179509705212d.tar.xz ruby-c60a0450734fba6463b1344df47179509705212d.zip | |
* bignum.c (big2str_karatsuba): initialize cache if not initialized.
* bignum.c (Init_Bignum): delayed initializing cache.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | bignum.c | 7 |
2 files changed, 11 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Mon Feb 25 15:33:29 2008 NAKAMURA Usaku <usa@ruby-lang.org> + + * bignum.c (big2str_karatsuba): initialize cache if not initialized. + + * bignum.c (Init_Bignum): delayed initializing cache. + Mon Feb 25 13:40:03 2008 Tanaka Akira <akr@fsij.org> * process.c (Init_process): share bignum objects for RLIM_INFINITY, @@ -737,6 +737,7 @@ ceil_log2(register unsigned long x) #define MAX_BIG2STR_TABLE_ENTRIES 64 static VALUE big2str_power_cache[35][MAX_BIG2STR_TABLE_ENTRIES]; +static int power_cache_initialized = 0; static void power_cache_init(void) @@ -901,6 +902,10 @@ big2str_karatsuba(VALUE x, int base, char* ptr, return big2str_orig(x, base, ptr, len, hbase, trim); } + if (!power_cache_initialized) { + power_cache_init(); + power_cache_initialized = 1; + } b = power_cache_get_power(base, n1, &m1); bigdivmod(x, b, &q, &r); lh = big2str_karatsuba(q, base, ptr, (len - m1)/2, @@ -2605,6 +2610,4 @@ Init_Bignum(void) rb_define_method(rb_cBignum, "size", rb_big_size, 0); rb_define_method(rb_cBignum, "odd?", rb_big_odd_p, 0); rb_define_method(rb_cBignum, "even?", rb_big_even_p, 0); - - power_cache_init(); } |
