зеркало из https://github.com/github/ruby.git
* bignum.c (MAX_BASE36_POWER_TABLE_ENTRIES): Renamed from
MAX_BIG2STR_TABLE_ENTRIES. (base36_power_cache): Renamed from big2str_power_cache. (base36_numdigits_cache): Renamed from big2str_numdigits_cache. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6660c5fb0c
Коммит
36c89c484b
|
@ -1,3 +1,10 @@
|
|||
Sat Aug 3 13:30:04 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (MAX_BASE36_POWER_TABLE_ENTRIES): Renamed from
|
||||
MAX_BIG2STR_TABLE_ENTRIES.
|
||||
(base36_power_cache): Renamed from big2str_power_cache.
|
||||
(base36_numdigits_cache): Renamed from big2str_numdigits_cache.
|
||||
|
||||
Sat Aug 3 10:33:52 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (parser_set_integer_literal): use rb_rational_raw1() for
|
||||
|
|
36
bignum.c
36
bignum.c
|
@ -4108,18 +4108,18 @@ big_rshift(VALUE x, unsigned long shift)
|
|||
return big_shift3(x, 0, s1, s2);
|
||||
}
|
||||
|
||||
#define MAX_BIG2STR_TABLE_ENTRIES (SIZEOF_SIZE_T * CHAR_BIT + 1)
|
||||
#define MAX_BASE36_POWER_TABLE_ENTRIES (SIZEOF_SIZE_T * CHAR_BIT + 1)
|
||||
|
||||
static VALUE big2str_power_cache[35][MAX_BIG2STR_TABLE_ENTRIES];
|
||||
static size_t big2str_numdigits_cache[35][MAX_BIG2STR_TABLE_ENTRIES];
|
||||
static VALUE base36_power_cache[35][MAX_BASE36_POWER_TABLE_ENTRIES];
|
||||
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_BIG2STR_TABLE_ENTRIES; ++j) {
|
||||
big2str_power_cache[i][j] = Qnil;
|
||||
for (j = 0; j < MAX_BASE36_POWER_TABLE_ENTRIES; ++j) {
|
||||
base36_power_cache[i][j] = Qnil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4128,23 +4128,23 @@ static inline VALUE
|
|||
power_cache_get_power(int base, int power_level, size_t *numdigits_ret)
|
||||
{
|
||||
/*
|
||||
* MAX_BIG2STR_TABLE_ENTRIES is big enough to that
|
||||
* big2str_power_cache[base][MAX_BIG2STR_TABLE_ENTRIES-1] fills whole memory.
|
||||
* So MAX_BIG2STR_TABLE_ENTRIES <= power_level is not possible to calculate.
|
||||
* MAX_BASE36_POWER_TABLE_ENTRIES is big enough to that
|
||||
* base36_power_cache[base][MAX_BASE36_POWER_TABLE_ENTRIES-1] fills whole memory.
|
||||
* So MAX_BASE36_POWER_TABLE_ENTRIES <= power_level is not possible to calculate.
|
||||
*
|
||||
* number-of-bytes =
|
||||
* log256(big2str_power_cache[base][MAX_BIG2STR_TABLE_ENTRIES-1]) =
|
||||
* log256(maxpow_in_bdigit_dbl(base)**(2**(MAX_BIG2STR_TABLE_ENTRIES-1))) =
|
||||
* log256(base36_power_cache[base][MAX_BASE36_POWER_TABLE_ENTRIES-1]) =
|
||||
* log256(maxpow_in_bdigit_dbl(base)**(2**(MAX_BASE36_POWER_TABLE_ENTRIES-1))) =
|
||||
* log256(maxpow_in_bdigit_dbl(base)**(2**(SIZEOF_SIZE_T*CHAR_BIT))) =
|
||||
* (2**(SIZEOF_SIZE_T*CHAR_BIT))*log256(maxpow_in_bdigit_dbl(base)) =
|
||||
* (256**SIZEOF_SIZE_T)*log256(maxpow_in_bdigit_dbl(base)) >
|
||||
* (256**SIZEOF_SIZE_T)*(sizeof(BDIGIT_DBL)-1) >
|
||||
* 256**SIZEOF_SIZE_T
|
||||
*/
|
||||
if (MAX_BIG2STR_TABLE_ENTRIES <= power_level)
|
||||
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(big2str_power_cache[base - 2][power_level])) {
|
||||
if (NIL_P(base36_power_cache[base - 2][power_level])) {
|
||||
VALUE power;
|
||||
size_t numdigits;
|
||||
if (power_level == 0) {
|
||||
|
@ -4160,13 +4160,13 @@ power_cache_get_power(int base, int power_level, size_t *numdigits_ret)
|
|||
numdigits *= 2;
|
||||
}
|
||||
rb_obj_hide(power);
|
||||
big2str_power_cache[base - 2][power_level] = power;
|
||||
big2str_numdigits_cache[base - 2][power_level] = numdigits;
|
||||
base36_power_cache[base - 2][power_level] = power;
|
||||
base36_numdigits_cache[base - 2][power_level] = numdigits;
|
||||
rb_gc_register_mark_object(power);
|
||||
}
|
||||
if (numdigits_ret)
|
||||
*numdigits_ret = big2str_numdigits_cache[base - 2][power_level];
|
||||
return big2str_power_cache[base - 2][power_level];
|
||||
*numdigits_ret = base36_numdigits_cache[base - 2][power_level];
|
||||
return base36_power_cache[base - 2][power_level];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4444,12 +4444,12 @@ rb_big2str1(VALUE x, int base)
|
|||
|
||||
power_level = 0;
|
||||
power = power_cache_get_power(base, power_level, NULL);
|
||||
while (power_level < MAX_BIG2STR_TABLE_ENTRIES &&
|
||||
while (power_level < MAX_BASE36_POWER_TABLE_ENTRIES &&
|
||||
RBIGNUM_LEN(power) <= (RBIGNUM_LEN(x)+1)/2) {
|
||||
power_level++;
|
||||
power = power_cache_get_power(base, power_level, NULL);
|
||||
}
|
||||
assert(power_level != MAX_BIG2STR_TABLE_ENTRIES);
|
||||
assert(power_level != MAX_BASE36_POWER_TABLE_ENTRIES);
|
||||
|
||||
if (RBIGNUM_LEN(power) <= RBIGNUM_LEN(x)) {
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче