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

ruby-changes:29958

From: akr <ko1@a...>
Date: Wed, 17 Jul 2013 00:17:32 +0900 (JST)
Subject: [ruby-changes:29958] akr:r42010 (trunk): * bignum.c (bigmul1_toom3): Use bigdivrem_single instead of bigdivrem.

akr	2013-07-17 00:17:21 +0900 (Wed, 17 Jul 2013)

  New Revision: 42010

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

  Log:
    * bignum.c (bigmul1_toom3): Use bigdivrem_single instead of bigdivrem.
      (big_three): Removed.
      (Init_Bignum): Don't initialize big_three.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42009)
+++ ChangeLog	(revision 42010)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jul 17 00:14:59 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (bigmul1_toom3): Use bigdivrem_single instead of bigdivrem.
+	  (big_three): Removed.
+	  (Init_Bignum): Don't initialize big_three.
+
 Tue Jul 16 21:46:03 2013  Masaki Matsushita  <glass.saga@g...>
 
 	* configure.in: revert r42008. strcasecmp() uses the current locale.
Index: bignum.c
===================================================================
--- bignum.c	(revision 42009)
+++ bignum.c	(revision 42010)
@@ -28,8 +28,6 @@ https://github.com/ruby/ruby/blob/trunk/bignum.c#L28
 VALUE rb_cBignum;
 const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
 
-static VALUE big_three = Qnil;
-
 #ifndef SIZEOF_BDIGIT_DBL
 # if defined(HAVE_INT64_T) && defined(HAVE_INT128_T)
 #  define SIZEOF_BDIGIT_DBL SIZEOF_INT128_T
@@ -115,6 +113,7 @@ typedef void (mulfunc_t)(BDIGIT *zds, si https://github.com/ruby/ruby/blob/trunk/bignum.c#L113
 
 static mulfunc_t bary_mul_toom3_start;
 static mulfunc_t bary_mul_karatsuba_start;
+static BDIGIT bigdivrem_single(BDIGIT *qds, BDIGIT *xds, long nx, BDIGIT y);
 static void bary_divmod(BDIGIT *qds, size_t nq, BDIGIT *rds, size_t nr, BDIGIT *xds, size_t nx, BDIGIT *yds, size_t ny);
 
 static VALUE bigmul0(VALUE x, VALUE y);
@@ -4732,7 +4731,7 @@ bigmul1_toom3(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L4731
 
     /* z3 <- (z(-2) - z(1)) / 3 == (u3 - u1) / 3 */
     z3 = bigadd(u3, u1, 0);
-    bigdivrem(z3, big_three, &z3, NULL); /* TODO: optimize */
+    bigdivrem_single(BDIGITS(z3), BDIGITS(z3), RBIGNUM_LEN(z3), 3);
     bigtrunc(z3);
 
     /* z1 <- (z(1) - z(-1)) / 2 == (u1 - u2) / 2 */
@@ -6079,7 +6078,4 @@ Init_Bignum(void) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6078
     rb_define_method(rb_cBignum, "even?", rb_big_even_p, 0);
 
     power_cache_init();
-
-    big_three = rb_uint2big(3);
-    rb_gc_register_mark_object(big_three);
 }

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

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