summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-29 11:07:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-29 11:07:45 +0000
commit8e6e8e628888aa251f771ce8b3fe30a6b41a7a0e (patch)
treee531ed455f2ffb110e9a16de2161b3865a19d582 /numeric.c
parent68f97d7851481e11ce90bb349345dc4caed00cf7 (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 'numeric.c')
-rw-r--r--numeric.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/numeric.c b/numeric.c
index 18f5e1cd1a..6d3c1432e8 100644
--- a/numeric.c
+++ b/numeric.c
@@ -204,7 +204,7 @@ do_coerce(VALUE *x, VALUE *y, int err)
a[0] = *x; a[1] = *y;
ary = rb_rescue(coerce_body, (VALUE)a, err?coerce_rescue:0, (VALUE)a);
- if (TYPE(ary) != T_ARRAY || RARRAY_LEN(ary) != 2) {
+ if (!RB_TYPE_P(ary, T_ARRAY) || RARRAY_LEN(ary) != 2) {
if (err) {
rb_raise(rb_eTypeError, "coerce must return [x, y]");
}
@@ -1272,7 +1272,7 @@ flo_le(VALUE x, VALUE y)
static VALUE
flo_eql(VALUE x, VALUE y)
{
- if (TYPE(y) == T_FLOAT) {
+ if (RB_TYPE_P(y, T_FLOAT)) {
double a = RFLOAT_VALUE(x);
double b = RFLOAT_VALUE(y);
#if defined(_MSC_VER) && _MSC_VER < 1300
@@ -1480,7 +1480,7 @@ int_round_0(VALUE num, int ndigits)
if (neg) x = -x;
return LONG2NUM(x);
}
- if (TYPE(f) == T_FLOAT) {
+ if (RB_TYPE_P(f, T_FLOAT)) {
/* then int_pow overflow */
return INT2FIX(0);
}
@@ -1676,7 +1676,7 @@ num_truncate(VALUE num)
int
ruby_float_step(VALUE from, VALUE to, VALUE step, int excl)
{
- if (TYPE(from) == T_FLOAT || TYPE(to) == T_FLOAT || TYPE(step) == T_FLOAT) {
+ if (RB_TYPE_P(from, T_FLOAT) || RB_TYPE_P(to, T_FLOAT) || RB_TYPE_P(step, T_FLOAT)) {
const double epsilon = DBL_EPSILON;
double beg = NUM2DBL(from);
double end = NUM2DBL(to);
@@ -2960,7 +2960,7 @@ fix_rev(VALUE num)
static VALUE
bit_coerce(VALUE x)
{
- while (!FIXNUM_P(x) && TYPE(x) != T_BIGNUM) {
+ while (!FIXNUM_P(x) && !RB_TYPE_P(x, T_BIGNUM)) {
rb_raise(rb_eTypeError,
"can't convert %s into Integer for bitwise arithmetic",
rb_obj_classname(x));