summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-29 12:22:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-29 12:22:01 +0000
commite878df745ca89ecdb07090ad2bb99fd433dfc3a3 (patch)
treef19ee613be1c68c4167b2b34415543bfa5c4e4a5
parenteb56c1084d57e59b9daab78b22812660d890a354 (diff)
use RB_TYPE_P
* enumerator.c (enumerator_initialize), eval.c (rb_using_refinement), (add_activated_refinement), numeric.c (num_interval_step_size), parse.y (arg, match_op_gen, cond0), range.c (range_bsearch), vm_insnhelper.c (vm_get_iclass): use RB_TYPE_P() to optimize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--enumerator.c2
-rw-r--r--eval.c4
-rw-r--r--numeric.c2
-rw-r--r--parse.y8
-rw-r--r--range.c2
-rw-r--r--vm_insnhelper.c4
6 files changed, 11 insertions, 11 deletions
diff --git a/enumerator.c b/enumerator.c
index 335b8c8..c563fa4 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -374,7 +374,7 @@ enumerator_initialize(int argc, VALUE *argv, VALUE obj)
recv = generator_init(generator_allocate(rb_cGenerator), rb_block_proc());
if (argc) {
if (NIL_P(argv[0]) || rb_obj_is_proc(argv[0]) ||
- (TYPE(argv[0]) == T_FLOAT && RFLOAT_VALUE(argv[0]) == INFINITY)) {
+ (RB_TYPE_P(argv[0], T_FLOAT) && RFLOAT_VALUE(argv[0]) == INFINITY)) {
size = argv[0];
} else {
size = rb_to_int(argv[0]);
diff --git a/eval.c b/eval.c
index f6a7b5d..c2b1753 100644
--- a/eval.c
+++ b/eval.c
@@ -1066,7 +1066,7 @@ rb_using_refinement(NODE *cref, VALUE klass, VALUE module)
}
if (!NIL_P(c = rb_hash_lookup(cref->nd_refinements, klass))) {
superclass = c;
- while (c && TYPE(c) == T_ICLASS) {
+ while (c && RB_TYPE_P(c, T_ICLASS)) {
if (RBASIC(c)->klass == module) {
/* already used refinement */
return;
@@ -1127,7 +1127,7 @@ add_activated_refinement(VALUE activated_refinements,
if (!NIL_P(c = rb_hash_lookup(activated_refinements, klass))) {
superclass = c;
- while (c && TYPE(c) == T_ICLASS) {
+ while (c && RB_TYPE_P(c, T_ICLASS)) {
if (RBASIC(c)->klass == refinement) {
/* already used refinement */
return;
diff --git a/numeric.c b/numeric.c
index 1447f2f..52e2c36 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1800,7 +1800,7 @@ num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
result = delta / diff;
return LONG2FIX(result >= 0 ? result + 1 : 0);
}
- else if (TYPE(from) == T_FLOAT || TYPE(to) == T_FLOAT || TYPE(step) == T_FLOAT) {
+ else if (RB_TYPE_P(from, T_FLOAT) || RB_TYPE_P(to, T_FLOAT) || RB_TYPE_P(step, T_FLOAT)) {
double n = ruby_float_step_size(NUM2DBL(from), NUM2DBL(to), NUM2DBL(step), excl);
if (isinf(n)) return DBL2NUM(n);
diff --git a/parse.y b/parse.y
index 2b119d4..1b57719 100644
--- a/parse.y
+++ b/parse.y
@@ -2238,7 +2238,7 @@ arg : lhs '=' arg
{
/*%%%*/
$$ = match_op($1, $3);
- if (nd_type($1) == NODE_LIT && TYPE($1->nd_lit) == T_REGEXP) {
+ if (nd_type($1) == NODE_LIT && RB_TYPE_P($1->nd_lit, T_REGEXP)) {
$$ = reg_named_capture_assign($1->nd_lit, $$);
}
/*%
@@ -8370,7 +8370,7 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2)
return NEW_MATCH2(node1, node2);
case NODE_LIT:
- if (TYPE(node1->nd_lit) == T_REGEXP) {
+ if (RB_TYPE_P(node1->nd_lit, T_REGEXP)) {
return NEW_MATCH2(node1, node2);
}
}
@@ -8383,7 +8383,7 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2)
return NEW_MATCH3(node2, node1);
case NODE_LIT:
- if (TYPE(node2->nd_lit) == T_REGEXP) {
+ if (RB_TYPE_P(node2->nd_lit, T_REGEXP)) {
return NEW_MATCH3(node2, node1);
}
}
@@ -9138,7 +9138,7 @@ cond0(struct parser_params *parser, NODE *node)
break;
case NODE_LIT:
- if (TYPE(node->nd_lit) == T_REGEXP) {
+ if (RB_TYPE_P(node->nd_lit, T_REGEXP)) {
warn_unless_e_option(parser, node, "regex literal in condition");
nd_set_type(node, NODE_MATCH);
}
diff --git a/range.c b/range.c
index 43c3389..4f75789 100644
--- a/range.c
+++ b/range.c
@@ -580,7 +580,7 @@ range_bsearch(VALUE range)
if (!satisfied) return Qnil;
return INT2FIX(low);
}
- else if (TYPE(beg) == T_FLOAT || TYPE(end) == T_FLOAT) {
+ else if (RB_TYPE_P(beg, T_FLOAT) || RB_TYPE_P(end, T_FLOAT)) {
double low = RFLOAT_VALUE(rb_Float(beg));
double high = RFLOAT_VALUE(rb_Float(end));
double mid, org_high;
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index ad21b99..144fc1f 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -363,9 +363,9 @@ vm_check_if_namespace(VALUE klass)
static inline VALUE
vm_get_iclass(rb_control_frame_t *cfp, VALUE klass)
{
- if (TYPE(klass) == T_MODULE &&
+ if (RB_TYPE_P(klass, T_MODULE) &&
FL_TEST(klass, RMODULE_IS_OVERLAID) &&
- TYPE(cfp->klass) == T_ICLASS &&
+ RB_TYPE_P(cfp->klass, T_ICLASS) &&
RBASIC(cfp->klass)->klass == klass) {
return cfp->klass;
}