diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-29 11:07:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-29 11:07:45 +0000 |
commit | 8e6e8e628888aa251f771ce8b3fe30a6b41a7a0e (patch) | |
tree | e531ed455f2ffb110e9a16de2161b3865a19d582 /random.c | |
parent | 68f97d7851481e11ce90bb349345dc4caed00cf7 (diff) |
* use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r-- | random.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1035,7 +1035,7 @@ rand_range(struct MT* mt, VALUE range) if ((v = vmax = range_values(range, &beg, &end, &excl)) == Qfalse) return Qfalse; - if (TYPE(vmax) != T_FLOAT && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) { + if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) { long max; vmax = v; v = Qnil; @@ -1149,7 +1149,7 @@ random_rand(int argc, VALUE *argv, VALUE obj) if (NIL_P(vmax)) { v = Qnil; } - else if (TYPE(vmax) != T_FLOAT && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) { + else if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) { v = rand_int(&rnd->mt, v, 1); } else if (v = rb_check_to_float(vmax), !NIL_P(v)) { |