* bignum.c (big2str_orig): Simplified because RBIGNUM_LEN(x) <= 2 now.

(big2str_struct): Two fields added: hbase2, hbase2_numdigits.
  (rb_big2str1): Initialize above fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-07-31 21:33:14 +00:00
Родитель 835c555f7f
Коммит 39a00c6710
2 изменённых файлов: 22 добавлений и 16 удалений

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

@ -1,3 +1,9 @@
Thu Aug 1 06:28:48 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (big2str_orig): Simplified because RBIGNUM_LEN(x) <= 2 now.
(big2str_struct): Two fields added: hbase2, hbase2_numdigits.
(rb_big2str1): Initialize above fields.
Thu Aug 1 04:06:17 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/options.rb (RDoc#finish): include root path in include

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

@ -4216,6 +4216,8 @@ struct big2str_struct {
int base;
BDIGIT hbase;
int hbase_numdigits;
BDIGIT_DBL hbase2;
int hbase2_numdigits;
};
static size_t
@ -4223,27 +4225,24 @@ big2str_orig(struct big2str_struct *b2s, VALUE x, char* ptr, size_t len, int tri
{
long i = RBIGNUM_LEN(x);
size_t j = len;
int k;
BDIGIT* ds = BDIGITS(x);
BDIGIT_DBL num;
assert(i <= 2);
while (i && j > 0) {
long k = i;
BDIGIT_DBL num = 0;
num = 0;
if (0 < i)
num = ds[0];
if (1 < i)
num |= BIGUP(ds[1]);
while (k--) { /* x / hbase */
num = BIGUP(num) + ds[k];
ds[k] = (BDIGIT)(num / b2s->hbase);
num %= b2s->hbase;
}
if (trim && ds[i-1] == 0) i--;
k = b2s->hbase_numdigits;
while (k--) {
ptr[--j] = ruby_digitmap[num % b2s->base];
num /= b2s->base;
if (j <= 0) break;
if (trim && i == 0 && num == 0) break;
}
k = b2s->hbase2_numdigits;
while (k--) {
ptr[--j] = ruby_digitmap[num % b2s->base];
num /= b2s->base;
if (j <= 0) break;
if (trim && num == 0) break;
}
if (trim) {
while (j < len && ptr[j] == '0') j++;
@ -4372,6 +4371,7 @@ rb_big2str1(VALUE x, int base, int trim)
b2s_data.base = base;
b2s_data.hbase = maxpow_in_bdigit(base, &b2s_data.hbase_numdigits);
b2s_data.hbase2 = maxpow_in_bdigit_dbl(base, &b2s_data.hbase2_numdigits);
off = !(trim && RBIGNUM_SIGN(x)); /* erase plus sign if trim */
xx = rb_big_clone(x);
RBIGNUM_SET_SIGN(xx, 1);