* bignum.c (bary_mul_precheck): Use bary_small_lshift or

bary_mul_normal if xl is 1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-07-13 15:16:23 +00:00
Родитель de79b66f46
Коммит f9029004ee
2 изменённых файлов: 22 добавлений и 8 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sun Jul 14 00:14:15 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (bary_mul_precheck): Use bary_small_lshift or
bary_mul_normal if xl is 1.
Sat Jul 13 22:58:16 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (big_shift3): New function.

Просмотреть файл

@ -1903,14 +1903,23 @@ bary_mul_precheck(BDIGIT **zdsp, size_t *zlp, BDIGIT **xdsp, size_t *xlp, BDIGIT
return 1;
}
if (xl == 1 && xds[0] == 1) {
MEMCPY(zds, yds, BDIGIT, yl);
MEMZERO(zds + yl, BDIGIT, zl - yl);
return 1;
}
if (yl == 1 && yds[0] == 1) {
MEMCPY(zds, xds, BDIGIT, xl);
MEMZERO(zds + xl, BDIGIT, zl - xl);
if (xl == 1) {
if (xds[0] == 1) {
MEMCPY(zds, yds, BDIGIT, yl);
MEMZERO(zds+yl, BDIGIT, zl-yl);
return 1;
}
if (POW2_P(xds[0])) {
zds[yl] = bary_small_lshift(zds, yds, yl, bitsize(xds[0])-1);
MEMZERO(zds+yl+1, BDIGIT, zl-yl-1);
return 1;
}
if (yl == 1 && yds[0] == 1) {
zds[0] = xds[0];
MEMZERO(zds+1, BDIGIT, zl-1);
return 1;
}
bary_mul_normal(zds, zl, xds, xl, yds, yl);
return 1;
}