summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-05 15:39:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-05 15:39:26 +0000
commit95512f277788ec12b4d368e337dc7397944e1183 (patch)
treeed41e3526e58fdb1e2952a36615ee56e365faa16
parent306a16d20126d1ec6e9d06f508aa95dd32ebe086 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--include/ruby/ruby.h10
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 48208799e9..1dabe8517e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-Mon Aug 6 00:38:52 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Aug 6 00:39:24 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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.
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 6c13a26588..9bb00133bd 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -514,7 +514,15 @@ rb_num2long_inline(VALUE x)
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);