mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* bignum.c (bigdivrem_single1): Renamed from bigdivrem_single. Add
x_higher_bdigit argument. (bigdivrem_single): Just call bigdivrem_single1. (bigdivrem_restoring): Use bigdivrem_single1 to avoid memmove. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9f6c62ad5f
commit
dcd4832d69
2 changed files with 20 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Fri Aug 16 10:07:59 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* bignum.c (bigdivrem_single1): Renamed from bigdivrem_single. Add
|
||||||
|
x_higher_bdigit argument.
|
||||||
|
(bigdivrem_single): Just call bigdivrem_single1.
|
||||||
|
(bigdivrem_restoring): Use bigdivrem_single1 to avoid memmove.
|
||||||
|
|
||||||
Fri Aug 16 09:17:00 2013 Tanaka Akira <akr@fsij.org>
|
Fri Aug 16 09:17:00 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bignum.c (bary_small_rshift): Specify the higher BDIGIT instead of
|
* bignum.c (bary_small_rshift): Specify the higher BDIGIT instead of
|
||||||
|
|
20
bignum.c
20
bignum.c
|
@ -2677,19 +2677,20 @@ bigdivrem_num_extra_words(size_t xn, size_t yn)
|
||||||
}
|
}
|
||||||
|
|
||||||
static BDIGIT
|
static BDIGIT
|
||||||
bigdivrem_single(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT y)
|
bigdivrem_single1(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT x_higher_bdigit, BDIGIT y)
|
||||||
{
|
{
|
||||||
assert(0 < xn);
|
assert(0 < xn);
|
||||||
|
assert(x_higher_bdigit < y);
|
||||||
if (POW2_P(y)) {
|
if (POW2_P(y)) {
|
||||||
BDIGIT r;
|
BDIGIT r;
|
||||||
r = xds[0] & (y-1);
|
r = xds[0] & (y-1);
|
||||||
bary_small_rshift(qds, xds, xn, bitsize(y)-1, 0);
|
bary_small_rshift(qds, xds, xn, bitsize(y)-1, x_higher_bdigit);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size_t i;
|
size_t i;
|
||||||
BDIGIT_DBL t2;
|
BDIGIT_DBL t2;
|
||||||
t2 = 0;
|
t2 = x_higher_bdigit;
|
||||||
i = xn;
|
i = xn;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
t2 = BIGUP(t2) + xds[i];
|
t2 = BIGUP(t2) + xds[i];
|
||||||
|
@ -2700,6 +2701,12 @@ bigdivrem_single(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BDIGIT
|
||||||
|
bigdivrem_single(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT y)
|
||||||
|
{
|
||||||
|
return bigdivrem_single1(qds, xds, xn, 0, y);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bigdivrem_restoring(BDIGIT *zds, size_t zn, BDIGIT *yds, size_t yn)
|
bigdivrem_restoring(BDIGIT *zds, size_t zn, BDIGIT *yds, size_t yn)
|
||||||
{
|
{
|
||||||
|
@ -2707,15 +2714,14 @@ bigdivrem_restoring(BDIGIT *zds, size_t zn, BDIGIT *yds, size_t yn)
|
||||||
size_t ynzero;
|
size_t ynzero;
|
||||||
|
|
||||||
assert(BDIGIT_MSB(yds[yn-1]));
|
assert(BDIGIT_MSB(yds[yn-1]));
|
||||||
|
assert(zds[zn-1] < yds[yn-1]);
|
||||||
|
|
||||||
for (ynzero = 0; !yds[ynzero]; ynzero++);
|
for (ynzero = 0; !yds[ynzero]; ynzero++);
|
||||||
|
|
||||||
if (ynzero+1 == yn) {
|
if (ynzero+1 == yn) {
|
||||||
BDIGIT r;
|
BDIGIT r;
|
||||||
r = bigdivrem_single(zds+ynzero, zds+ynzero, zn-ynzero, yds[yn-1]);
|
r = bigdivrem_single1(zds+yn, zds+ynzero, zn-yn, zds[zn-1], yds[ynzero]);
|
||||||
assert(zds[zn-1] == 0);
|
zds[ynzero] = r;
|
||||||
MEMMOVE(zds+yn, zds+yn-1, BDIGIT, zn - yn);
|
|
||||||
zds[yn-1] = r;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue