ruby-changes:32073
From: mrkn <ko1@a...>
Date: Fri, 13 Dec 2013 02:02:32 +0900 (JST)
Subject: [ruby-changes:32073] mrkn:r44152 (trunk): * ext/bigdecimal/bigdecimal.c (VpAddAbs): put out a conditional branch from
mrkn 2013-12-13 02:02:24 +0900 (Fri, 13 Dec 2013) New Revision: 44152 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44152 Log: * ext/bigdecimal/bigdecimal.c (VpAddAbs): put out a conditional branch from the inside of while-loop. * ext/bigdecimal/bigdecimal.c (VpSubAbs): ditto. Modified files: trunk/ChangeLog trunk/ext/bigdecimal/bigdecimal.c Index: ChangeLog =================================================================== --- ChangeLog (revision 44151) +++ ChangeLog (revision 44152) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Dec 13 01:56:00 2013 Kenta Murata <mrkn@m...> + + * ext/bigdecimal/bigdecimal.c (VpAddAbs): put out a conditional branch from + the inside of while-loop. + + * ext/bigdecimal/bigdecimal.c (VpSubAbs): ditto. + Wed Dec 13 01:53:00 2013 Kenta Murata <mrkn@m...> * ext/bigdecimal/bigdecimal.c (VPrint): be a static function, support another Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 44151) +++ ext/bigdecimal/bigdecimal.c (revision 44152) @@ -4196,14 +4196,14 @@ VpAddAbs(Real *a, Real *b, Real *c) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4196 /* Just assign the last few digits of b to c because a has no */ /* corresponding digits to be added. */ - while (b_pos + word_shift > a_pos) { - --c_pos; - if (b_pos > 0) { - c->frac[c_pos] = b->frac[--b_pos]; + if (b_pos > 0) { + while (b_pos > 0 && b_pos + word_shift > a_pos) { + c->frac[--c_pos] = b->frac[--b_pos]; } - else { - --word_shift; - c->frac[c_pos] = 0; + } + if (b_pos == 0 && word_shift > a_pos) { + while (word_shift-- > a_pos) { + c->frac[--c_pos] = 0; } } @@ -4299,16 +4299,16 @@ VpSubAbs(Real *a, Real *b, Real *c) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4299 /* each of the last few digits of the b because the a has no */ /* corresponding digits to be subtracted. */ if (b_pos + word_shift > a_pos) { - while (b_pos + word_shift > a_pos) { - --c_pos; - if (b_pos > 0) { - c->frac[c_pos] = BASE - b->frac[--b_pos] - borrow; - } - else { + while (b_pos > 0 && b_pos + word_shift > a_pos) { + c->frac[--c_pos] = BASE - b->frac[--b_pos] - borrow; + borrow = 1; + } + if (b_pos == 0) { + while (word_shift > a_pos) { --word_shift; - c->frac[c_pos] = BASE - borrow; + c->frac[--c_pos] = BASE - borrow; + borrow = 1; } - borrow = 1; } } /* Just assign the last few digits of a to c because b has no */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/