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

ruby-changes:28953

From: akr <ko1@a...>
Date: Fri, 31 May 2013 23:57:14 +0900 (JST)
Subject: [ruby-changes:28953] akr:r41005 (trunk): * bignum.c (calc_hbase): Extracted from rb_big2str0.

akr	2013-05-31 23:57:03 +0900 (Fri, 31 May 2013)

  New Revision: 41005

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

  Log:
    * bignum.c (calc_hbase): Extracted from rb_big2str0.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41004)
+++ ChangeLog	(revision 41005)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri May 31 23:56:13 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (calc_hbase): Extracted from rb_big2str0.
+
 Fri May 31 23:22:24 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c: Don't hard code SIZEOF_BDIGITS for log_base(hbase).
Index: bignum.c
===================================================================
--- bignum.c	(revision 41004)
+++ bignum.c	(revision 41005)
@@ -1119,6 +1119,23 @@ big2str_karatsuba(VALUE x, int base, cha https://github.com/ruby/ruby/blob/trunk/bignum.c#L1119
     return lh + ll;
 }
 
+static void
+calc_hbase(int base, long *hbase_p, int *hbase_numdigits_p)
+{
+    long hbase;
+    int hbase_numdigits;
+
+    hbase = base*base;
+    hbase_numdigits = 2;
+#if SIZEOF_BDIGITS > 2
+    hbase *= hbase;
+    hbase_numdigits *= 2;
+#endif
+
+    *hbase_p = hbase;
+    *hbase_numdigits_p = hbase_numdigits;
+}
+
 VALUE
 rb_big2str0(VALUE x, int base, int trim)
 {
@@ -1144,12 +1161,7 @@ rb_big2str0(VALUE x, int base, int trim) https://github.com/ruby/ruby/blob/trunk/bignum.c#L1161
     ptr = RSTRING_PTR(ss);
     ptr[0] = RBIGNUM_SIGN(x) ? '+' : '-';
 
-    hbase = base*base;
-    hbase_numdigits = 2;
-#if SIZEOF_BDIGITS > 2
-    hbase *= hbase;
-    hbase_numdigits *= 2;
-#endif
+    calc_hbase(base, &hbase, &hbase_numdigits);
     off = !(trim && RBIGNUM_SIGN(x)); /* erase plus sign if trim */
     xx = rb_big_clone(x);
     RBIGNUM_SET_SIGN(xx, 1);

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

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