From 70d72bf807bf50672e64d431320f2e62c98ba6aa Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 7 Mar 2010 14:15:24 +0000 Subject: [PATCH] * 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 --- ChangeLog | 5 +++++ bignum.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7472c829d..28ffbe45cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 7 23:14:22 2010 Tanaka Akira + + * bignum.c (rb_big_pack): use DIGSPERLONG and BITSPERDIG. + (rb_big_unpack): use DIGSPERLONG. + Sun Mar 7 19:21:10 2010 Marc-Andre Lafortune * io.c: Fix documentation for each/each_line/lines, bytes/each_byte, diff --git a/bignum.c b/bignum.c index 0074ba77dc..e79e5f4888 100644 --- a/bignum.c +++ b/bignum.c @@ -342,8 +342,8 @@ rb_big_pack(VALUE val, unsigned long *buf, long num_longs) long i, j; for (i = 0; i < num_longs && ds < dend; i++) { unsigned long l = 0; - for (j = 0; j < SIZEOF_LONG/SIZEOF_BDIGITS && ds < dend; j++, ds++) { - l |= ((unsigned long)*ds << (j * SIZEOF_BDIGITS * CHAR_BIT)); + for (j = 0; j < DIGSPERLONG && ds < dend; j++, ds++) { + l |= ((unsigned long)*ds << (j * BITSPERDIG)); } buf[i] = l; } @@ -381,7 +381,7 @@ rb_big_unpack(unsigned long *buf, long num_longs) else { VALUE big; BDIGIT *ds; - long len = num_longs * (SIZEOF_LONG/SIZEOF_BDIGITS); + long len = num_longs * DIGSPERLONG; long i; big = bignew(len, 1); ds = BDIGITS(big); @@ -391,7 +391,7 @@ rb_big_unpack(unsigned long *buf, long num_longs) *ds++ = d; #else int j; - for (j = 0; j < SIZEOF_LONG/SIZEOF_BDIGITS; j++) { + for (j = 0; j < DIGSPERLONG; j++) { *ds++ = BIGLO(d); d = BIGDN(d); }