diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-08 12:05:57 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-08 12:05:57 +0000 |
commit | 747894a32d6ea2b123b2abc292fd903c53a7aa36 (patch) | |
tree | c6a59d1b30a97c752b4367aa6ffb9050a609f74f /time.c | |
parent | af612be8e0e54ffa602cede04d355a1399a02b81 (diff) | |
download | ruby-747894a32d6ea2b123b2abc292fd903c53a7aa36.tar.gz |
* bignum.c (rb_absint_singlebit_p): New function.
* internal.h (rb_absint_singlebit_p): Declared.
* time.c (v2w_bignum): Use rb_absint_singlebit_p instead of
rb_big_abs_find_minbit.
(rb_big_abs_find_minbit): Removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 22 |
1 files changed, 1 insertions, 21 deletions
@@ -313,25 +313,6 @@ rb_big_abs_find_maxbit(VALUE big) return res; } -static VALUE -rb_big_abs_find_minbit(VALUE big) -{ - BDIGIT *ds = RBIGNUM_DIGITS(big); - BDIGIT d; - long len = RBIGNUM_LEN(big); - long i; - VALUE res; - for (i = 0; i < len; i++) - if (ds[i]) - break; - if (i == len) - return Qnil; - res = mul(LONG2NUM(i), INT2FIX(SIZEOF_BDIGITS * CHAR_BIT)); - d = ds[i]; - res = add(res, LONG2FIX(ffs(d)-1)); - return res; -} - static wideval_t v2w_bignum(VALUE v) { @@ -346,8 +327,7 @@ v2w_bignum(VALUE v) return WINT2FIXWV(0); if (lt(maxbit, INT2FIX(sizeof(wideint_t) * CHAR_BIT - 2)) || (eq(maxbit, INT2FIX(sizeof(wideint_t) * CHAR_BIT - 2)) && - RBIGNUM_NEGATIVE_P(v) && - eq(rb_big_abs_find_minbit(v), INT2FIX(sizeof(wideint_t) * CHAR_BIT - 2)))) { + RBIGNUM_NEGATIVE_P(v) && rb_absint_singlebit_p(v))) { wideint_t i; i = 0; while (len) |