From 8e6e8e628888aa251f771ce8b3fe30a6b41a7a0e Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 29 Sep 2011 11:07:45 +0000 Subject: * 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 --- complex.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index a701129b73..fd0088c574 100644 --- a/complex.c +++ b/complex.c @@ -121,7 +121,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) @@ -130,7 +130,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) @@ -166,14 +166,14 @@ fun1(real_p) 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); } @@ -944,7 +944,7 @@ nucomp_coerce(VALUE self, VALUE other) { if (k_numeric_p(other) && f_real_p(other)) return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self); - if (TYPE(other) == T_COMPLEX) + if (RB_TYPE_P(other, T_COMPLEX)) return rb_assoc_new(other, self); rb_raise(rb_eTypeError, "%s can't be coerced into %s", -- cgit v1.2.3