* bignum.c (bigdivrem1): optimization by skipping zeros at the
tail of digits. a patch from TOYOFUKU Chikanobu <nobu_toyofuku at nifty.com> in [ruby-dev:36169]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c8573378f6
commit
7a04666b3c
@ -12,6 +12,12 @@ Sat Sep 6 07:24:49 2008 Tanaka Akira <akr@fsij.org>
|
|||||||
* io.c (rb_io_extract_modeenc): raise an error for ASCII incompatible
|
* io.c (rb_io_extract_modeenc): raise an error for ASCII incompatible
|
||||||
encoding without binmode.
|
encoding without binmode.
|
||||||
|
|
||||||
|
Sat Sep 6 07:12:42 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* bignum.c (bigdivrem1): optimization by skipping zeros at the
|
||||||
|
tail of digits. a patch from TOYOFUKU Chikanobu
|
||||||
|
<nobu_toyofuku at nifty.com> in [ruby-dev:36169].
|
||||||
|
|
||||||
Sat Sep 6 06:28:46 2008 Tanaka Akira <akr@fsij.org>
|
Sat Sep 6 06:28:46 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* enc/trans/escape.trans: new file.
|
* enc/trans/escape.trans: new file.
|
||||||
|
5
bignum.c
5
bignum.c
@ -1633,19 +1633,20 @@ bigdivrem1(void *ptr)
|
|||||||
{
|
{
|
||||||
struct big_div_struct *bds = (struct big_div_struct*)ptr;
|
struct big_div_struct *bds = (struct big_div_struct*)ptr;
|
||||||
long nx = bds->nx, ny = bds->ny;
|
long nx = bds->nx, ny = bds->ny;
|
||||||
long i, j;
|
long i, j, nyzero;
|
||||||
BDIGIT *yds = bds->yds, *zds = bds->zds;
|
BDIGIT *yds = bds->yds, *zds = bds->zds;
|
||||||
BDIGIT_DBL t2;
|
BDIGIT_DBL t2;
|
||||||
BDIGIT_DBL_SIGNED num;
|
BDIGIT_DBL_SIGNED num;
|
||||||
BDIGIT q;
|
BDIGIT q;
|
||||||
|
|
||||||
j = nx==ny?nx+1:nx;
|
j = nx==ny?nx+1:nx;
|
||||||
|
for (nyzero = 0; !yds[nyzero]; nyzero++);
|
||||||
do {
|
do {
|
||||||
if (bds->stop) return Qnil;
|
if (bds->stop) return Qnil;
|
||||||
if (zds[j] == yds[ny-1]) q = BIGRAD-1;
|
if (zds[j] == yds[ny-1]) q = BIGRAD-1;
|
||||||
else q = (BDIGIT)((BIGUP(zds[j]) + zds[j-1])/yds[ny-1]);
|
else q = (BDIGIT)((BIGUP(zds[j]) + zds[j-1])/yds[ny-1]);
|
||||||
if (q) {
|
if (q) {
|
||||||
i = 0; num = 0; t2 = 0;
|
i = nyzero; num = 0; t2 = 0;
|
||||||
do { /* multiply and subtract */
|
do { /* multiply and subtract */
|
||||||
BDIGIT_DBL ee;
|
BDIGIT_DBL ee;
|
||||||
t2 += (BDIGIT_DBL)yds[i] * q;
|
t2 += (BDIGIT_DBL)yds[i] * q;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user