mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
eb56c1084d
commit
e878df745c
6 changed files with 11 additions and 11 deletions
|
@ -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]);
|
||||
|
|
4
eval.c
4
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;
|
||||
|
|
|
@ -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);
|
||||
|
|
8
parse.y
8
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);
|
||||
}
|
||||
|
|
2
range.c
2
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue