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

ruby-changes:36468

From: nobu <ko1@a...>
Date: Mon, 24 Nov 2014 12:44:23 +0900 (JST)
Subject: [ruby-changes:36468] nobu:r48550 (trunk): marshal.c: literal method names

nobu	2014-11-24 12:43:59 +0900 (Mon, 24 Nov 2014)

  New Revision: 48550

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

  Log:
    marshal.c: literal method names
    
    * marshal.c (check_dump_arg, check_load_arg): use literal method
      names, instead of converting from ID every time.

  Modified files:
    trunk/marshal.c
Index: marshal.c
===================================================================
--- marshal.c	(revision 48549)
+++ marshal.c	(revision 48550)
@@ -85,6 +85,19 @@ static ID s_dump, s_load, s_mdump, s_mlo https://github.com/ruby/ruby/blob/trunk/marshal.c#L85
 static ID s_dump_data, s_load_data, s_alloc, s_call;
 static ID s_getbyte, s_read, s_write, s_binmode;
 
+#define name_s_dump	"_dump"
+#define name_s_load	"_load"
+#define name_s_mdump	"marshal_dump"
+#define name_s_mload	"marshal_load"
+#define name_s_dump_data "_dump_data"
+#define name_s_load_data "_load_data"
+#define name_s_alloc	"_alloc"
+#define name_s_call	"call"
+#define name_s_getbyte	"getbyte"
+#define name_s_read	"read"
+#define name_s_write	"write"
+#define name_s_binmode	"binmode"
+
 typedef struct {
     VALUE newclass;
     VALUE oldclass;
@@ -151,13 +164,14 @@ struct dump_call_arg { https://github.com/ruby/ruby/blob/trunk/marshal.c#L164
 };
 
 static void
-check_dump_arg(struct dump_arg *arg, ID sym)
+check_dump_arg(struct dump_arg *arg, const char *name)
 {
     if (!arg->symbols) {
         rb_raise(rb_eRuntimeError, "Marshal.dump reentered at %s",
-		 rb_id2name(sym));
+		 name);
     }
 }
+#define check_dump_arg(arg, sym) check_dump_arg(arg, name_##sym)
 
 static void clear_dump_arg(struct dump_arg *arg);
 
@@ -1032,13 +1046,14 @@ struct load_arg { https://github.com/ruby/ruby/blob/trunk/marshal.c#L1046
 };
 
 static void
-check_load_arg(struct load_arg *arg, ID sym)
+check_load_arg(struct load_arg *arg, const char *name)
 {
     if (!arg->symbols) {
         rb_raise(rb_eRuntimeError, "Marshal.load reentered at %s",
-		 rb_id2name(sym));
+		 name);
     }
 }
+#define check_load_arg(arg, sym) check_load_arg(arg, name_##sym)
 
 static void clear_load_arg(struct load_arg *arg);
 
@@ -2154,19 +2169,19 @@ Init_marshal(void) https://github.com/ruby/ruby/blob/trunk/marshal.c#L2169
 #define rb_intern(str) rb_intern_const(str)
 
     VALUE rb_mMarshal = rb_define_module("Marshal");
-
-    s_dump = rb_intern("_dump");
-    s_load = rb_intern("_load");
-    s_mdump = rb_intern("marshal_dump");
-    s_mload = rb_intern("marshal_load");
-    s_dump_data = rb_intern("_dump_data");
-    s_load_data = rb_intern("_load_data");
-    s_alloc = rb_intern("_alloc");
-    s_call = rb_intern("call");
-    s_getbyte = rb_intern("getbyte");
-    s_read = rb_intern("read");
-    s_write = rb_intern("write");
-    s_binmode = rb_intern("binmode");
+#define set_id(sym) sym = rb_intern_const(name_##sym)
+    set_id(s_dump);
+    set_id(s_load);
+    set_id(s_mdump);
+    set_id(s_mload);
+    set_id(s_dump_data);
+    set_id(s_load_data);
+    set_id(s_alloc);
+    set_id(s_call);
+    set_id(s_getbyte);
+    set_id(s_read);
+    set_id(s_write);
+    set_id(s_binmode);
 
     rb_define_module_function(rb_mMarshal, "dump", marshal_dump, -1);
     rb_define_module_function(rb_mMarshal, "load", marshal_load, -1);

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

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