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

ruby-changes:30464

From: akr <ko1@a...>
Date: Tue, 13 Aug 2013 23:04:12 +0900 (JST)
Subject: [ruby-changes:30464] akr:r42543 (trunk): * bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.

akr	2013-08-13 23:03:55 +0900 (Tue, 13 Aug 2013)

  New Revision: 42543

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

  Log:
    * bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42542)
+++ ChangeLog	(revision 42543)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Aug 13 23:01:16 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.
+
 Tue Aug 13 22:12:59 2013  Kenichi Kamiya  <kachick1@g...>
 
 	* random.c (rb_random_ulong_limited): coerce before check negative.
Index: bignum.c
===================================================================
--- bignum.c	(revision 42542)
+++ bignum.c	(revision 42543)
@@ -2697,23 +2697,11 @@ bigdivrem_single(BDIGIT *qds, const BDIG https://github.com/ruby/ruby/blob/trunk/bignum.c#L2697
 }
 
 static void
-bigdivrem_normal(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, BDIGIT *yds, size_t yn, int needs_mod)
+bigdivrem_restoring(BDIGIT *zds, size_t zn, size_t xn, BDIGIT *yds, size_t yn)
 {
     struct big_div_struct bds;
-    BDIGIT q;
-    int shift;
 
-    q = yds[yn-1];
-    shift = nlz(q);
-    if (shift) {
-        bary_small_lshift(yds, yds, yn, shift);
-        zds[xn] = bary_small_lshift(zds, xds, xn, shift);
-    }
-    else {
-        MEMCPY(zds, xds, BDIGIT, xn);
-	zds[xn] = 0;
-    }
-    if (xn+1 < zn) zds[xn+1] = 0;
+    assert(BDIGIT_MSB(yds[yn-1]));
 
     bds.xn = xn;
     bds.yn = yn;
@@ -2735,6 +2723,27 @@ bigdivrem_normal(BDIGIT *zds, size_t zn, https://github.com/ruby/ruby/blob/trunk/bignum.c#L2723
     else {
 	bigdivrem1(&bds);
     }
+}
+
+static void
+bigdivrem_normal(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, BDIGIT *yds, size_t yn, int needs_mod)
+{
+    BDIGIT q;
+    int shift;
+
+    q = yds[yn-1];
+    shift = nlz(q);
+    if (shift) {
+        bary_small_lshift(yds, yds, yn, shift);
+        zds[xn] = bary_small_lshift(zds, xds, xn, shift);
+    }
+    else {
+        MEMCPY(zds, xds, BDIGIT, xn);
+	zds[xn] = 0;
+    }
+    if (xn+1 < zn) zds[xn+1] = 0;
+
+    bigdivrem_restoring(zds, zn, xn, yds, yn);
 
     if (needs_mod && shift) {
         bary_small_rshift(zds, zds, yn, shift, 0);

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

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