1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* bignum.c (rb_big_pack): use DIGSPERLONG and BITSPERDIG.

(rb_big_unpack): use DIGSPERLONG.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-03-07 14:15:24 +00:00
parent 51ae7f6e9a
commit 70d72bf807
2 changed files with 9 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Sun Mar 7 23:14:22 2010 Tanaka Akira <akr@fsij.org>
* bignum.c (rb_big_pack): use DIGSPERLONG and BITSPERDIG.
(rb_big_unpack): use DIGSPERLONG.
Sun Mar 7 19:21:10 2010 Marc-Andre Lafortune <ruby-core@marc-andre.ca> Sun Mar 7 19:21:10 2010 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* io.c: Fix documentation for each/each_line/lines, bytes/each_byte, * io.c: Fix documentation for each/each_line/lines, bytes/each_byte,

View file

@ -342,8 +342,8 @@ rb_big_pack(VALUE val, unsigned long *buf, long num_longs)
long i, j; long i, j;
for (i = 0; i < num_longs && ds < dend; i++) { for (i = 0; i < num_longs && ds < dend; i++) {
unsigned long l = 0; unsigned long l = 0;
for (j = 0; j < SIZEOF_LONG/SIZEOF_BDIGITS && ds < dend; j++, ds++) { for (j = 0; j < DIGSPERLONG && ds < dend; j++, ds++) {
l |= ((unsigned long)*ds << (j * SIZEOF_BDIGITS * CHAR_BIT)); l |= ((unsigned long)*ds << (j * BITSPERDIG));
} }
buf[i] = l; buf[i] = l;
} }
@ -381,7 +381,7 @@ rb_big_unpack(unsigned long *buf, long num_longs)
else { else {
VALUE big; VALUE big;
BDIGIT *ds; BDIGIT *ds;
long len = num_longs * (SIZEOF_LONG/SIZEOF_BDIGITS); long len = num_longs * DIGSPERLONG;
long i; long i;
big = bignew(len, 1); big = bignew(len, 1);
ds = BDIGITS(big); ds = BDIGITS(big);
@ -391,7 +391,7 @@ rb_big_unpack(unsigned long *buf, long num_longs)
*ds++ = d; *ds++ = d;
#else #else
int j; int j;
for (j = 0; j < SIZEOF_LONG/SIZEOF_BDIGITS; j++) { for (j = 0; j < DIGSPERLONG; j++) {
*ds++ = BIGLO(d); *ds++ = BIGLO(d);
d = BIGDN(d); d = BIGDN(d);
} }