* bignum.c (rb_absint_size): Use numberof.

(rb_int_export): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-06-07 10:24:07 +00:00
parent bd15d4ca78
commit 84d8e58249
2 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Fri Jun 7 19:23:15 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (rb_absint_size): Use numberof.
(rb_int_export): Ditto.
Fri Jun 7 18:58:56 2013 Tanaka Akira <akr@fsij.org> Fri Jun 7 18:58:56 2013 Tanaka Akira <akr@fsij.org>
* internal.h (numberof): Gathered from various files. * internal.h (numberof): Gathered from various files.

View File

@ -473,14 +473,14 @@ rb_absint_size(VALUE val, int *number_of_leading_zero_bits)
#else #else
{ {
int i; int i;
for (i = 0; i < (int)(sizeof(fixbuf)/sizeof(*fixbuf)); i++) { for (i = 0; i < numberof(fixbuf); i++) {
fixbuf[i] = (BDIGIT)(v & ((1L << (SIZEOF_BDIGITS * CHAR_BIT)) - 1)); fixbuf[i] = (BDIGIT)(v & ((1L << (SIZEOF_BDIGITS * CHAR_BIT)) - 1));
v >>= SIZEOF_BDIGITS * CHAR_BIT; v >>= SIZEOF_BDIGITS * CHAR_BIT;
} }
} }
#endif #endif
dp = fixbuf; dp = fixbuf;
de = fixbuf + sizeof(fixbuf)/sizeof(*fixbuf); de = fixbuf + numberof(fixbuf);
} }
else { else {
dp = BDIGITS(val); dp = BDIGITS(val);
@ -626,14 +626,14 @@ rb_int_export(VALUE val, int *signp, size_t *wordcount_allocated, void *words, s
#else #else
{ {
int i; int i;
for (i = 0; i < (int)(sizeof(fixbuf)/sizeof(*fixbuf)); i++) { for (i = 0; i < numberof(fixbuf); i++) {
fixbuf[i] = (BDIGIT)(v & ((1L << (SIZEOF_BDIGITS * CHAR_BIT)) - 1)); fixbuf[i] = (BDIGIT)(v & ((1L << (SIZEOF_BDIGITS * CHAR_BIT)) - 1));
v >>= SIZEOF_BDIGITS * CHAR_BIT; v >>= SIZEOF_BDIGITS * CHAR_BIT;
} }
} }
#endif #endif
dp = fixbuf; dp = fixbuf;
de = fixbuf + sizeof(fixbuf)/sizeof(*fixbuf); de = fixbuf + numberof(fixbuf);
} }
else { else {
sign = RBIGNUM_POSITIVE_P(val) ? 1 : -1; sign = RBIGNUM_POSITIVE_P(val) ? 1 : -1;