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

ruby-changes:29283

From: akr <ko1@a...>
Date: Sun, 16 Jun 2013 17:49:37 +0900 (JST)
Subject: [ruby-changes:29283] akr:r41335 (trunk): * bignum.c (absint_numwords_generic): rb_funcall invocations removed.

akr	2013-06-16 17:49:26 +0900 (Sun, 16 Jun 2013)

  New Revision: 41335

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

  Log:
    * bignum.c (absint_numwords_generic): rb_funcall invocations removed.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41334)
+++ ChangeLog	(revision 41335)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jun 16 17:48:14 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (absint_numwords_generic): rb_funcall invocations removed.
+
 Sun Jun 16 16:04:38 2013  NARUSE, Yui  <naruse@r...>
 
 	* tool/config_files.rb: use URI.read to allow it runs with Ruby 1.8.5.
Index: bignum.c
===================================================================
--- bignum.c	(revision 41334)
+++ bignum.c	(revision 41335)
@@ -600,12 +600,6 @@ absint_numwords_small(size_t numbytes, i https://github.com/ruby/ruby/blob/trunk/bignum.c#L600
 static size_t
 absint_numwords_generic(size_t numbytes, int nlz_bits_in_msbyte, size_t word_numbits, size_t *nlz_bits_ret)
 {
-    VALUE val_numbits, word_numbits_v;
-    VALUE div_mod, div, mod;
-    int sign;
-    size_t numwords;
-    size_t nlz_bits;
-
     BDIGIT numbytes_bary[bdigit_roomof(sizeof(numbytes))];
     BDIGIT char_bit[1] = { CHAR_BIT };
     BDIGIT val_numbits_bary[bdigit_roomof(sizeof(numbytes) + 1)];
@@ -614,11 +608,10 @@ absint_numwords_generic(size_t numbytes, https://github.com/ruby/ruby/blob/trunk/bignum.c#L608
     BDIGIT div_bary[numberof(val_numbits_bary) + BIGDIVREM_EXTRA_WORDS];
     BDIGIT mod_bary[numberof(word_numbits_bary)];
     BDIGIT one[1] = { 1 };
-    size_t nlz_bits0;
-    size_t mod0;
-    int sign0;
-    size_t numwords0;
-    VALUE vm;
+    size_t nlz_bits;
+    size_t mod;
+    int sign;
+    size_t numwords;
 
     /*
      * val_numbits = numbytes * CHAR_BIT - nlz_bits_in_msbyte
@@ -636,42 +629,17 @@ absint_numwords_generic(size_t numbytes, https://github.com/ruby/ruby/blob/trunk/bignum.c#L629
         INTEGER_PACK_NATIVE_BYTE_ORDER);
     bary_divmod(BARY_ARGS(div_bary), BARY_ARGS(mod_bary), BARY_ARGS(val_numbits_bary), BARY_ARGS(word_numbits_bary));
     if (bary_zero_p(BARY_ARGS(mod_bary))) {
-        nlz_bits0 = 0;
-        vm = rb_integer_unpack(mod_bary, numberof(mod_bary), sizeof(BDIGIT), 0,
-                INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
+        nlz_bits = 0;
     }
     else {
         bary_add(BARY_ARGS(div_bary), BARY_ARGS(div_bary), BARY_ARGS(one));
-        bary_pack(+1, BARY_ARGS(mod_bary), &mod0, 1, sizeof(mod0), 0,
+        bary_pack(+1, BARY_ARGS(mod_bary), &mod, 1, sizeof(mod), 0,
             INTEGER_PACK_NATIVE_BYTE_ORDER, 0);
-        vm = rb_integer_unpack(mod_bary, numberof(mod_bary), sizeof(BDIGIT), 0,
-                INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
-        assert(NUM2SIZET(vm) == mod0);
-        nlz_bits0 = word_numbits - NUM2SIZET(vm);
+        nlz_bits = word_numbits - mod;
     }
-    sign0 = bary_pack(+1, BARY_ARGS(div_bary), &numwords0, 1, sizeof(numwords), 0,
+    sign = bary_pack(+1, BARY_ARGS(div_bary), &numwords, 1, sizeof(numwords), 0,
         INTEGER_PACK_NATIVE_BYTE_ORDER, 0);
 
-    val_numbits = SIZET2NUM(numbytes);
-    val_numbits = rb_funcall(val_numbits, '*', 1, LONG2FIX(CHAR_BIT));
-    if (nlz_bits_in_msbyte)
-        val_numbits = rb_funcall(val_numbits, '-', 1, LONG2FIX(nlz_bits_in_msbyte));
-    word_numbits_v = SIZET2NUM(word_numbits);
-    div_mod = rb_funcall(val_numbits, rb_intern("divmod"), 1, word_numbits_v);
-    div = RARRAY_AREF(div_mod, 0);
-    mod = RARRAY_AREF(div_mod, 1);
-    if (mod == LONG2FIX(0)) {
-        nlz_bits = 0;
-    }
-    else {
-        div = rb_funcall(div, '+', 1, LONG2FIX(1));
-        nlz_bits = word_numbits - NUM2SIZET(mod);
-    }
-    sign = rb_integer_pack(div, &numwords, 1, sizeof(numwords), 0,
-        INTEGER_PACK_NATIVE_BYTE_ORDER);
-    assert(nlz_bits == nlz_bits0);
-    assert(sign == sign0);
-    assert(numwords == numwords0);
     if (sign == 2)
         return (size_t)-1;
     *nlz_bits_ret = nlz_bits;

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

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