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

* bignum.c (big_div_struct): ynzero field removed.

(bigdivrem1): Follow the above change.
  (bigdivrem_restoring): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-08-13 14:43:10 +00:00
parent adaa5650cd
commit 26e69a89fa
2 changed files with 19 additions and 13 deletions

View file

@ -1,3 +1,9 @@
Tue Aug 13 23:38:17 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (big_div_struct): ynzero field removed.
(bigdivrem1): Follow the above change.
(bigdivrem_restoring): Ditto.
Tue Aug 13 23:01:16 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.

View file

@ -2625,7 +2625,7 @@ bary_mul(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds
}
struct big_div_struct {
size_t xn, yn, j, ynzero;
size_t xn, yn, j;
BDIGIT *yds, *zds;
volatile VALUE stop;
};
@ -2636,7 +2636,6 @@ bigdivrem1(void *ptr)
struct big_div_struct *bds = (struct big_div_struct*)ptr;
size_t yn = bds->yn;
size_t j;
size_t ynzero = bds->ynzero;
BDIGIT *yds = bds->yds, *zds = bds->zds;
BDIGIT_DBL_SIGNED num;
BDIGIT q;
@ -2650,14 +2649,14 @@ bigdivrem1(void *ptr)
if (zds[j] == yds[yn-1]) q = BDIGMAX;
else q = (BDIGIT)((BIGUP(zds[j]) + zds[j-1])/yds[yn-1]);
if (q) {
num = bigdivrem_mulsub(zds+j-(yn-ynzero), yn-ynzero+1,
num = bigdivrem_mulsub(zds+j-yn, yn+1,
q,
yds+ynzero, yn-ynzero);
yds, yn);
while (num) { /* "add back" required */
q--;
num = bary_add(zds+j-(yn-ynzero), yn-ynzero,
zds+j-(yn-ynzero), yn-ynzero,
yds+ynzero, yn-ynzero);
num = bary_add(zds+j-yn, yn,
zds+j-yn, yn,
yds, yn);
num--;
}
}
@ -2700,16 +2699,17 @@ static void
bigdivrem_restoring(BDIGIT *zds, size_t zn, size_t xn, BDIGIT *yds, size_t yn)
{
struct big_div_struct bds;
size_t ynzero;
assert(BDIGIT_MSB(yds[yn-1]));
bds.xn = xn;
bds.yn = yn;
bds.zds = zds;
bds.yds = yds;
for (ynzero = 0; !yds[ynzero]; ynzero++);
bds.xn = xn - ynzero;
bds.yn = yn - ynzero;
bds.zds = zds + ynzero;
bds.yds = yds + ynzero;
bds.stop = Qfalse;
bds.j = zn - 1;
for (bds.ynzero = 0; !yds[bds.ynzero]; bds.ynzero++);
bds.j = zn - 1 - ynzero;
if (xn > 10000 || yn > 10000) {
retry:
bds.stop = Qfalse;