mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
306a16d201
commit
95512f2777
2 changed files with 14 additions and 2 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue