summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-24 03:43:59 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-24 03:43:59 (GMT)
commitec81f9c4cda263f77d0a84946b4d412ebd3a875a (patch)
tree12d96a1bd1fabc793527b96c619950b543a6db3e /marshal.c
parent25bab786cb416aa491ff62e6d9b6ba196251bfc6 (diff)
marshal.c: literal method names
* marshal.c (check_dump_arg, check_load_arg): use literal method names, instead of converting from ID every time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/marshal.c b/marshal.c
index 40546a7..de6ed60 100644
--- a/marshal.c
+++ b/marshal.c
@@ -85,6 +85,19 @@ static ID s_dump, s_load, s_mdump, s_mload;
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 {
};
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 {
};
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)
#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);