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

ruby-changes:27541

From: nobu <ko1@a...>
Date: Tue, 5 Mar 2013 10:20:26 +0900 (JST)
Subject: [ruby-changes:27541] nobu:r39593 (trunk): numeric.c: optimize for Bignum

nobu	2013-03-05 10:18:55 +0900 (Tue, 05 Mar 2013)

  New Revision: 39593

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

  Log:
    numeric.c: optimize for Bignum
    
    * numeric.c (rb_int_succ, rb_int_pred): shortcut optimization for
      Bignum.

  Modified files:
    trunk/ChangeLog
    trunk/numeric.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39592)
+++ ChangeLog	(revision 39593)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Mar  5 10:19:09 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* numeric.c (rb_int_succ, rb_int_pred): shortcut optimization for
+	  Bignum.
+
 Tue Mar  5 10:02:48 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/rubygems/ext/ext_conf_builder.rb (Gem::Ext::ExtConfBuilder.build):
Index: numeric.c
===================================================================
--- numeric.c	(revision 39592)
+++ numeric.c	(revision 39593)
@@ -2390,6 +2390,9 @@ int_succ(VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2390
 	long i = FIX2LONG(num) + 1;
 	return LONG2NUM(i);
     }
+    if (RB_TYPE_P(num, T_BIGNUM)) {
+	return rb_big_plus(num, INT2FIX(1));
+    }
     return rb_funcall(num, '+', 1, INT2FIX(1));
 }
 
@@ -2410,6 +2413,9 @@ int_pred(VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2413
 	long i = FIX2LONG(num) - 1;
 	return LONG2NUM(i);
     }
+    if (RB_TYPE_P(num, T_BIGNUM)) {
+	return rb_big_minus(num, INT2FIX(1));
+    }
     return rb_funcall(num, '-', 1, INT2FIX(1));
 }
 

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

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