mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* time.c (rb_big_abs_find_maxbit): Use rb_absint_size.
(bdigit_find_maxbit): Removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b512e61ca0
commit
af612be8e0
2 changed files with 14 additions and 36 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Jun 8 20:24:23 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* time.c (rb_big_abs_find_maxbit): Use rb_absint_size.
|
||||||
|
(bdigit_find_maxbit): Removed.
|
||||||
|
|
||||||
Sat Jun 8 19:47:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
|
Sat Jun 8 19:47:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
|
||||||
|
|
||||||
* class.c (include_modules_at): invalidate method cache if included
|
* class.c (include_modules_at): invalidate method cache if included
|
||||||
|
|
45
time.c
45
time.c
|
@ -296,47 +296,20 @@ w2v(wideval_t w)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WIDEVALUE_IS_WIDER
|
#if WIDEVALUE_IS_WIDER
|
||||||
static int
|
|
||||||
bdigit_find_maxbit(BDIGIT d)
|
|
||||||
{
|
|
||||||
int res = 0;
|
|
||||||
if (d & ~(BDIGIT)0xffff) {
|
|
||||||
d >>= 16;
|
|
||||||
res += 16;
|
|
||||||
}
|
|
||||||
if (d & ~(BDIGIT)0xff) {
|
|
||||||
d >>= 8;
|
|
||||||
res += 8;
|
|
||||||
}
|
|
||||||
if (d & ~(BDIGIT)0xf) {
|
|
||||||
d >>= 4;
|
|
||||||
res += 4;
|
|
||||||
}
|
|
||||||
if (d & ~(BDIGIT)0x3) {
|
|
||||||
d >>= 2;
|
|
||||||
res += 2;
|
|
||||||
}
|
|
||||||
if (d & ~(BDIGIT)0x1) {
|
|
||||||
d >>= 1;
|
|
||||||
res += 1;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_big_abs_find_maxbit(VALUE big)
|
rb_big_abs_find_maxbit(VALUE big)
|
||||||
{
|
{
|
||||||
BDIGIT *ds = RBIGNUM_DIGITS(big);
|
int num_zeros;
|
||||||
BDIGIT d;
|
size_t bytesize;
|
||||||
long len = RBIGNUM_LEN(big);
|
|
||||||
VALUE res;
|
VALUE res;
|
||||||
while (0 < len && ds[len-1] == 0)
|
|
||||||
len--;
|
bytesize = rb_absint_size(big, &num_zeros);
|
||||||
if (len == 0)
|
if (bytesize == 0)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
res = mul(LONG2NUM(len-1), INT2FIX(SIZEOF_BDIGITS * CHAR_BIT));
|
|
||||||
d = ds[len-1];
|
res = mul(SIZET2NUM(bytesize), LONG2FIX(CHAR_BIT));
|
||||||
res = add(res, LONG2FIX(bdigit_find_maxbit(d)));
|
if (num_zeros)
|
||||||
|
res = sub(res, LONG2FIX(num_zeros));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue