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

ruby-changes:38859

From: normal <ko1@a...>
Date: Thu, 18 Jun 2015 06:07:24 +0900 (JST)
Subject: [ruby-changes:38859] normal:r50940 (trunk): compile.c: use %+PRIsVALUE instead of rb_inspect

normal	2015-06-18 06:07:02 +0900 (Thu, 18 Jun 2015)

  New Revision: 50940

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

  Log:
    compile.c: use %+PRIsVALUE instead of rb_inspect
    
    * compile.c (get_exception_sym2type, iseq_build_from_ary_body):
      rely on %+PRIsVALUE instead of calling rb_inspect directly
    
    This yields a minor size reduction on 32-bit x86:
    
       text	   data	    bss	    dec	    hex	filename
      96807	    772	     48	  97627	  17d5b	compile.o
      96851	    772	     48	  97671	  17d87	compile.orig

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50939)
+++ ChangeLog	(revision 50940)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun 18 06:02:42 2015  Eric Wong  <e@8...>
+
+	* compile.c (get_exception_sym2type, iseq_build_from_ary_body):
+	  rely on %+PRIsVALUE instead of calling rb_inspect directly
+
 Wed Jun 17 20:59:25 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (ENC_MK): needs fake.rb if cross compilation.
Index: compile.c
===================================================================
--- compile.c	(revision 50939)
+++ compile.c	(revision 50940)
@@ -5792,7 +5792,6 @@ get_exception_sym2type(VALUE sym) https://github.com/ruby/ruby/blob/trunk/compile.c#L5792
 {
 #undef rb_intern
 #define rb_intern(str) rb_intern_const(str)
-    VALUE sym_inspect;
     static VALUE symRescue, symEnsure, symRetry;
     static VALUE symBreak, symRedo, symNext;
 
@@ -5811,9 +5810,7 @@ get_exception_sym2type(VALUE sym) https://github.com/ruby/ruby/blob/trunk/compile.c#L5810
     if (sym == symBreak)  return CATCH_TYPE_BREAK;
     if (sym == symRedo)   return CATCH_TYPE_REDO;
     if (sym == symNext)   return CATCH_TYPE_NEXT;
-    sym_inspect = rb_inspect(sym);
-    rb_raise(rb_eSyntaxError, "invalid exception symbol: %s",
-	     StringValuePtr(sym_inspect));
+    rb_raise(rb_eSyntaxError, "invalid exception symbol: %+"PRIsVALUE, sym);
     return 0;
 }
 
@@ -5965,8 +5962,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L5962
 	    if (st_lookup(insn_table, (st_data_t)insn, &insn_id) == 0) {
 		/* TODO: exception */
 		rb_compile_error(RSTRING_PTR(iseq->location.path), line_no,
-				 "unknown instruction: %"PRIsVALUE,
-				 rb_inspect(insn));
+				 "unknown instruction: %+"PRIsVALUE, insn);
 	    }
 
 	    if (argc != insn_len((VALUE)insn_id)-1) {

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

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