[前][次][番号順一覧][スレッド一覧]

ruby-changes:7650

From: matz <ko1@a...>
Date: Sat, 6 Sep 2008 08:25:28 +0900 (JST)
Subject: [ruby-changes:7650] Ruby:r19171 (trunk): * bignum.c (bigdivrem1): optimization by skipping zeros at the

matz	2008-09-06 08:25:13 +0900 (Sat, 06 Sep 2008)

  New Revision: 19171

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19171

  Log:
    * 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].

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19170)
+++ ChangeLog	(revision 19171)
@@ -12,6 +12,12 @@
 	* io.c (rb_io_extract_modeenc): raise an error for ASCII incompatible
 	  encoding without binmode.
 
+Sat Sep  6 07:12:42 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* 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@f...>
 
 	* enc/trans/escape.trans: new file.
Index: bignum.c
===================================================================
--- bignum.c	(revision 19170)
+++ bignum.c	(revision 19171)
@@ -1633,19 +1633,20 @@
 {
     struct big_div_struct *bds = (struct big_div_struct*)ptr;
     long nx = bds->nx, ny = bds->ny;
-    long i, j;
+    long i, j, nyzero;
     BDIGIT *yds = bds->yds, *zds = bds->zds;
     BDIGIT_DBL t2;
     BDIGIT_DBL_SIGNED num;
     BDIGIT q;
 
     j = nx==ny?nx+1:nx;
+    for (nyzero = 0; !yds[nyzero]; nyzero++);
     do {
 	if (bds->stop) return Qnil;
 	if (zds[j] ==  yds[ny-1]) q = BIGRAD-1;
 	else q = (BDIGIT)((BIGUP(zds[j]) + zds[j-1])/yds[ny-1]);
 	if (q) {
-	    i = 0; num = 0; t2 = 0;
+           i = nyzero; num = 0; t2 = 0;
 	    do {			/* multiply and subtract */
 		BDIGIT_DBL ee;
 		t2 += (BDIGIT_DBL)yds[i] * q;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]