* bignum.c (rb_big_pow): Don't need to multiply SIZEOF_BDIGITS.
Use nlz instead of bitlength_bdigit. (bitlength_bdigit): Removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4eabe8193a
commit
14ec81b0a2
@ -1,3 +1,9 @@
|
|||||||
|
Wed Jun 5 08:13:37 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* bignum.c (rb_big_pow): Don't need to multiply SIZEOF_BDIGITS.
|
||||||
|
Use nlz instead of bitlength_bdigit.
|
||||||
|
(bitlength_bdigit): Removed.
|
||||||
|
|
||||||
Wed Jun 5 07:14:18 2013 Tadayoshi Funaba <tadf@dotrb.org>
|
Wed Jun 5 07:14:18 2013 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* ext/date/date_core.c (d_lite_cmp, d_lite_equal): simplified.
|
* ext/date/date_core.c (d_lite_cmp, d_lite_equal): simplified.
|
||||||
|
22
bignum.c
22
bignum.c
@ -3178,24 +3178,6 @@ bigsqr(VALUE x)
|
|||||||
return bigtrunc(bigmul0(x, x));
|
return bigtrunc(bigmul0(x, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
bitlength_bdigit(BDIGIT v)
|
|
||||||
{
|
|
||||||
if (v == 0)
|
|
||||||
return 0;
|
|
||||||
v |= v >> 1;
|
|
||||||
v |= v >> 2;
|
|
||||||
v |= v >> 4;
|
|
||||||
v |= v >> 8;
|
|
||||||
#if 2 < SIZEOF_BDIGITS
|
|
||||||
v |= v >> 16;
|
|
||||||
#endif
|
|
||||||
v++;
|
|
||||||
if (v == 0)
|
|
||||||
return SIZEOF_BDIGITS*CHAR_BIT;
|
|
||||||
return ffs(v)-1; /* assumption: sizeof(BDIGIT) <= sizeof(int) */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* big ** exponent -> numeric
|
* big ** exponent -> numeric
|
||||||
@ -3236,8 +3218,8 @@ rb_big_pow(VALUE x, VALUE y)
|
|||||||
else {
|
else {
|
||||||
VALUE z = 0;
|
VALUE z = 0;
|
||||||
SIGNED_VALUE mask;
|
SIGNED_VALUE mask;
|
||||||
const long xlen = RBIGNUM_LEN(x) - 1;
|
const long xlen = RBIGNUM_LEN(x);
|
||||||
const long xbits = bitlength_bdigit(RBIGNUM_DIGITS(x)[xlen]) + SIZEOF_BDIGITS*BITSPERDIG*xlen;
|
const long xbits = BITSPERDIG*xlen - nlz(RBIGNUM_DIGITS(x)[xlen-1]);
|
||||||
const long BIGLEN_LIMIT = BITSPERDIG*1024*1024;
|
const long BIGLEN_LIMIT = BITSPERDIG*1024*1024;
|
||||||
|
|
||||||
if ((xbits > BIGLEN_LIMIT) || (xbits * yy > BIGLEN_LIMIT)) {
|
if ((xbits > BIGLEN_LIMIT) || (xbits * yy > BIGLEN_LIMIT)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user