* bignum.c (big2str_karatsuba): Don't allocate new temporary buffer

if the buffer is enough for current invocation.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-08-03 16:01:14 +00:00
Родитель b3be3c29c4
Коммит 092511bac7
2 изменённых файлов: 10 добавлений и 4 удалений

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

@ -1,3 +1,8 @@
Sun Aug 4 00:57:58 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (big2str_karatsuba): Don't allocate new temporary buffer
if the buffer is enough for current invocation.
Sun Aug 4 00:22:34 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (bary2bdigitdbl): New function.

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

@ -4383,12 +4383,13 @@ big2str_karatsuba(struct big2str_struct *b2s, BDIGIT *xds, size_t xn,
memset(b2s->ptr, '0', len);
b2s->ptr += len;
}
if (wn < bn * 4 + BIGDIVREM_EXTRA_WORDS) {
wn = bn * 4 + BIGDIVREM_EXTRA_WORDS;
wds = ALLOCV_N(BDIGIT, tmpw, wn);
}
rn = bn;
qn = xn+BIGDIVREM_EXTRA_WORDS;
if (wn < rn + qn) {
wn = bn * 4 + BIGDIVREM_EXTRA_WORDS;
assert(rn + qn <= wn);
wds = ALLOCV_N(BDIGIT, tmpw, wn);
}
rds = wds;
qds = wds+rn;
bary_divmod(qds, qn, rds, rn, xds, xn, bds, bn);