[前][次][番号順一覧][スレッド一覧]

ruby-changes:26602

From: nobu <ko1@a...>
Date: Sat, 29 Dec 2012 21:25:36 +0900 (JST)
Subject: [ruby-changes:26602] nobu:r38653 (trunk): use RB_TYPE_P

nobu	2012-12-29 21:22:01 +0900 (Sat, 29 Dec 2012)

  New Revision: 38653

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38653

  Log:
    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.

  Modified files:
    trunk/enumerator.c
    trunk/eval.c
    trunk/numeric.c
    trunk/parse.y
    trunk/range.c
    trunk/vm_insnhelper.c

Index: enumerator.c
===================================================================
--- enumerator.c	(revision 38652)
+++ enumerator.c	(revision 38653)
@@ -374,7 +374,7 @@ enumerator_initialize(int argc, VALUE *a https://github.com/ruby/ruby/blob/trunk/enumerator.c#L374
 	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]);
Index: range.c
===================================================================
--- range.c	(revision 38652)
+++ range.c	(revision 38653)
@@ -580,7 +580,7 @@ range_bsearch(VALUE range) https://github.com/ruby/ruby/blob/trunk/range.c#L580
 	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;
Index: eval.c
===================================================================
--- eval.c	(revision 38652)
+++ eval.c	(revision 38653)
@@ -1066,7 +1066,7 @@ rb_using_refinement(NODE *cref, VALUE kl https://github.com/ruby/ruby/blob/trunk/eval.c#L1066
 	}
 	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 https://github.com/ruby/ruby/blob/trunk/eval.c#L1127
 
     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;
Index: parse.y
===================================================================
--- parse.y	(revision 38652)
+++ parse.y	(revision 38653)
@@ -2238,7 +2238,7 @@ arg		: lhs '=' arg https://github.com/ruby/ruby/blob/trunk/parse.y#L2238
 		    {
 		    /*%%%*/
 			$$ = 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 *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8370
 	    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 *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8383
 	    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 https://github.com/ruby/ruby/blob/trunk/parse.y#L9138
 	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);
 	}
Index: numeric.c
===================================================================
--- numeric.c	(revision 38652)
+++ numeric.c	(revision 38653)
@@ -1800,7 +1800,7 @@ num_interval_step_size(VALUE from, VALUE https://github.com/ruby/ruby/blob/trunk/numeric.c#L1800
 	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);
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 38652)
+++ vm_insnhelper.c	(revision 38653)
@@ -363,9 +363,9 @@ vm_check_if_namespace(VALUE klass) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L363
 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;
     }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]