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

ruby-changes:30492

From: akr <ko1@a...>
Date: Fri, 16 Aug 2013 01:16:36 +0900 (JST)
Subject: [ruby-changes:30492] akr:r42571 (trunk): * bignum.c (bigdivrem_restoring): Use bigdivrem_single if non-topmost

akr	2013-08-16 01:16:08 +0900 (Fri, 16 Aug 2013)

  New Revision: 42571

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

  Log:
    * bignum.c (bigdivrem_restoring): Use bigdivrem_single if non-topmost
      BDIGITs of y are zero.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42570)
+++ ChangeLog	(revision 42571)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Aug 16 01:09:33 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (bigdivrem_restoring): Use bigdivrem_single if non-topmost
+	  BDIGITs of y are zero.
+
 Fri Aug 16 00:33:12 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (rb_big2str1): Truncate topmost zeros of x.
Index: bignum.c
===================================================================
--- bignum.c	(revision 42570)
+++ bignum.c	(revision 42571)
@@ -2704,6 +2704,16 @@ bigdivrem_restoring(BDIGIT *zds, size_t https://github.com/ruby/ruby/blob/trunk/bignum.c#L2704
     assert(BDIGIT_MSB(yds[yn-1]));
 
     for (ynzero = 0; !yds[ynzero]; ynzero++);
+
+    if (ynzero+1 == yn) {
+        BDIGIT r;
+        r = bigdivrem_single(zds+ynzero, zds+ynzero, zn-ynzero, yds[yn-1]);
+        assert(zds[zn-1] == 0);
+        MEMMOVE(zds+yn, zds+yn-1, BDIGIT, zn - yn);
+        zds[yn-1] = r;
+        return;
+    }
+
     bds.yn = yn - ynzero;
     bds.zds = zds + ynzero;
     bds.yds = yds + ynzero;

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

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