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

ruby-changes:29904

From: akr <ko1@a...>
Date: Sun, 14 Jul 2013 00:16:40 +0900 (JST)
Subject: [ruby-changes:29904] akr:r41955 (trunk): * bignum.c (bary_mul_precheck): Use bary_small_lshift or

akr	2013-07-14 00:16:23 +0900 (Sun, 14 Jul 2013)

  New Revision: 41955

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

  Log:
    * bignum.c (bary_mul_precheck): Use bary_small_lshift or
      bary_mul_normal if xl is 1.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41954)
+++ ChangeLog	(revision 41955)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jul 14 00:14:15 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (bary_mul_precheck): Use bary_small_lshift or
+	  bary_mul_normal if xl is 1.
+
 Sat Jul 13 22:58:16 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (big_shift3): New function.
Index: bignum.c
===================================================================
--- bignum.c	(revision 41954)
+++ bignum.c	(revision 41955)
@@ -1903,14 +1903,23 @@ bary_mul_precheck(BDIGIT **zdsp, size_t https://github.com/ruby/ruby/blob/trunk/bignum.c#L1903
         return 1;
     }
 
-    if (xl == 1 && xds[0] == 1) {
-        MEMCPY(zds, yds, BDIGIT, yl);
-        MEMZERO(zds + yl, BDIGIT, zl - yl);
-        return 1;
-    }
-    if (yl == 1 && yds[0] == 1) {
-        MEMCPY(zds, xds, BDIGIT, xl);
-        MEMZERO(zds + xl, BDIGIT, zl - xl);
+    if (xl == 1) {
+        if (xds[0] == 1) {
+            MEMCPY(zds, yds, BDIGIT, yl);
+            MEMZERO(zds+yl, BDIGIT, zl-yl);
+            return 1;
+        }
+        if (POW2_P(xds[0])) {
+            zds[yl] = bary_small_lshift(zds, yds, yl, bitsize(xds[0])-1);
+            MEMZERO(zds+yl+1, BDIGIT, zl-yl-1);
+            return 1;
+        }
+        if (yl == 1 && yds[0] == 1) {
+            zds[0] = xds[0];
+            MEMZERO(zds+1, BDIGIT, zl-1);
+            return 1;
+        }
+        bary_mul_normal(zds, zl, xds, xl, yds, yl);
         return 1;
     }
 

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

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