diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-17 17:15:33 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-17 17:15:33 +0000 |
commit | e4b88e2334bacb03618078894dc5f92bc45c8bf1 (patch) | |
tree | ccd1476c348be3f9ae09e5741e9d1e5e7cb38ba2 /numeric.c | |
parent | 622460dd007f6036c37ff53cf62a118af83cb4ea (diff) | |
download | ruby-e4b88e2334bacb03618078894dc5f92bc45c8bf1.tar.gz |
* numeric.c (int_even_p): treat Fixnum and Bignum values directly.
I forgot include this commit in the previous one.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -2702,7 +2702,15 @@ int_odd_p(VALUE num) static VALUE int_even_p(VALUE num) { - if (rb_funcall(num, '%', 1, INT2FIX(2)) == INT2FIX(0)) { + if (FIXNUM_P(num)) { + if ((num & 2) == 0) { + return Qtrue; + } + } + else if (RB_TYPE_P(num, T_BIGNUM)) { + return rb_big_even_p(num); + } + else if (rb_funcall(num, '%', 1, INT2FIX(2)) == INT2FIX(0)) { return Qtrue; } return Qfalse; |