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

ruby-changes:24580

From: nobu <ko1@a...>
Date: Mon, 6 Aug 2012 00:39:40 +0900 (JST)
Subject: [ruby-changes:24580] nobu:r36631 (trunk): ruby.h: rb_num2ulong_inline

nobu	2012-08-06 00:39:26 +0900 (Mon, 06 Aug 2012)

  New Revision: 36631

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

  Log:
    ruby.h: rb_num2ulong_inline
    
    * include/ruby/ruby.h (NUM2ULONG): optimize by inline as well as
      NUM2LONG, and cast to unsigned long explicitly for the platforms
      where SIZEOF_VALUE is larger than SIZEOF_LONG.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/ruby.h

Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 36630)
+++ include/ruby/ruby.h	(revision 36631)
@@ -514,7 +514,15 @@
 	return (long)rb_num2long(x);
 }
 #define NUM2LONG(x) rb_num2long_inline(x)
-#define NUM2ULONG(x) rb_num2ulong(x)
+static inline unsigned long
+rb_num2ulong_inline(VALUE x)
+{
+    if (FIXNUM_P(x))
+	return (unsigned long)FIX2LONG(x);
+    else
+	return (unsigned long)rb_num2ulong(x);
+}
+#define NUM2ULONG(x) rb_num2ulong_inline(x)
 #if SIZEOF_INT < SIZEOF_LONG
 long rb_num2int(VALUE);
 long rb_fix2int(VALUE);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36630)
+++ ChangeLog	(revision 36631)
@@ -1,5 +1,9 @@
-Mon Aug  6 00:38:52 2012  Nobuyoshi Nakada  <nobu@r...>
+Mon Aug  6 00:39:24 2012  Nobuyoshi Nakada  <nobu@r...>
 
+	* include/ruby/ruby.h (NUM2ULONG): optimize by inline as well as
+	  NUM2LONG, and cast to unsigned long explicitly for the platforms
+	  where SIZEOF_VALUE is larger than SIZEOF_LONG.
+
 	* include/ruby/ruby.h (NUM2SSIZET): fix type to cast.
 
 Sun Aug  5 21:10:36 2012  Narihiro Nakamura  <authornari@g...>

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

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