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

ruby-changes:30465

From: akr <ko1@a...>
Date: Tue, 13 Aug 2013 23:43:17 +0900 (JST)
Subject: [ruby-changes:30465] akr:r42544 (trunk): * bignum.c (big_div_struct): ynzero field removed.

akr	2013-08-13 23:43:10 +0900 (Tue, 13 Aug 2013)

  New Revision: 42544

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

  Log:
    * bignum.c (big_div_struct): ynzero field removed.
      (bigdivrem1): Follow the above change.
      (bigdivrem_restoring): Ditto.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42543)
+++ ChangeLog	(revision 42544)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Aug 13 23:38:17 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (big_div_struct): ynzero field removed.
+	  (bigdivrem1): Follow the above change.
+	  (bigdivrem_restoring): Ditto.
+
 Tue Aug 13 23:01:16 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.
Index: bignum.c
===================================================================
--- bignum.c	(revision 42543)
+++ bignum.c	(revision 42544)
@@ -2625,7 +2625,7 @@ bary_mul(BDIGIT *zds, size_t zn, const B https://github.com/ruby/ruby/blob/trunk/bignum.c#L2625
 }
 
 struct big_div_struct {
-    size_t xn, yn, j, ynzero;
+    size_t xn, yn, j;
     BDIGIT *yds, *zds;
     volatile VALUE stop;
 };
@@ -2636,7 +2636,6 @@ bigdivrem1(void *ptr) https://github.com/ruby/ruby/blob/trunk/bignum.c#L2636
     struct big_div_struct *bds = (struct big_div_struct*)ptr;
     size_t yn = bds->yn;
     size_t j;
-    size_t ynzero = bds->ynzero;
     BDIGIT *yds = bds->yds, *zds = bds->zds;
     BDIGIT_DBL_SIGNED num;
     BDIGIT q;
@@ -2650,14 +2649,14 @@ bigdivrem1(void *ptr) https://github.com/ruby/ruby/blob/trunk/bignum.c#L2649
 	if (zds[j] == yds[yn-1]) q = BDIGMAX;
 	else q = (BDIGIT)((BIGUP(zds[j]) + zds[j-1])/yds[yn-1]);
 	if (q) {
-            num = bigdivrem_mulsub(zds+j-(yn-ynzero), yn-ynzero+1,
+            num = bigdivrem_mulsub(zds+j-yn, yn+1,
                                    q,
-                                   yds+ynzero, yn-ynzero);
+                                   yds, yn);
 	    while (num) { /* "add back" required */
 		q--;
-                num = bary_add(zds+j-(yn-ynzero), yn-ynzero,
-                               zds+j-(yn-ynzero), yn-ynzero,
-                               yds+ynzero, yn-ynzero);
+                num = bary_add(zds+j-yn, yn,
+                               zds+j-yn, yn,
+                               yds, yn);
                 num--;
 	    }
 	}
@@ -2700,16 +2699,17 @@ static void https://github.com/ruby/ruby/blob/trunk/bignum.c#L2699
 bigdivrem_restoring(BDIGIT *zds, size_t zn, size_t xn, BDIGIT *yds, size_t yn)
 {
     struct big_div_struct bds;
+    size_t ynzero;
 
     assert(BDIGIT_MSB(yds[yn-1]));
 
-    bds.xn = xn;
-    bds.yn = yn;
-    bds.zds = zds;
-    bds.yds = yds;
+    for (ynzero = 0; !yds[ynzero]; ynzero++);
+    bds.xn = xn - ynzero;
+    bds.yn = yn - ynzero;
+    bds.zds = zds + ynzero;
+    bds.yds = yds + ynzero;
     bds.stop = Qfalse;
-    bds.j = zn - 1;
-    for (bds.ynzero = 0; !yds[bds.ynzero]; bds.ynzero++);
+    bds.j = zn - 1 - ynzero;
     if (xn > 10000 || yn > 10000) {
       retry:
 	bds.stop = Qfalse;

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

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