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 /rational.c | |
parent | 68f97d7851481e11ce90bb349345dc4caed00cf7 (diff) | |
download | ruby-8e6e8e628888aa251f771ce8b3fe30a6b41a7a0e.tar.gz |
* 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 'rational.c')
-rw-r--r-- | rational.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rational.c b/rational.c index 40b480df6e..3af98c76c5 100644 --- a/rational.c +++ b/rational.c @@ -106,7 +106,7 @@ f_mul(VALUE x, VALUE y) if (FIXNUM_P(y)) { long iy = FIX2LONG(y); if (iy == 0) { - if (FIXNUM_P(x) || TYPE(x) == T_BIGNUM) + if (FIXNUM_P(x) || RB_TYPE_P(x, T_BIGNUM)) return ZERO; } else if (iy == 1) @@ -115,7 +115,7 @@ f_mul(VALUE x, VALUE y) else if (FIXNUM_P(x)) { long ix = FIX2LONG(x); if (ix == 0) { - if (FIXNUM_P(y) || TYPE(y) == T_BIGNUM) + if (FIXNUM_P(y) || RB_TYPE_P(y, T_BIGNUM)) return ZERO; } else if (ix == 1) @@ -141,14 +141,14 @@ fun1(negate) inline static VALUE f_to_i(VALUE x) { - if (TYPE(x) == T_STRING) + if (RB_TYPE_P(x, T_STRING)) return rb_str_to_inum(x, 10, 0); return rb_funcall(x, id_to_i, 0); } inline static VALUE f_to_f(VALUE x) { - if (TYPE(x) == T_STRING) + if (RB_TYPE_P(x, T_STRING)) return DBL2NUM(rb_str_to_dbl(x, 0)); return rb_funcall(x, id_to_f, 0); } @@ -2161,7 +2161,7 @@ string_to_r(VALUE self) a1 = RARRAY_PTR(a)[0]; if (!NIL_P(a1)) { - if (TYPE(a1) == T_FLOAT) + if (RB_TYPE_P(a1, T_FLOAT)) rb_raise(rb_eFloatDomainError, "Infinity"); return a1; } |