summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-10 11:38:49 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-10 11:38:49 +0900
commitab31693af109022ecc0a01107067d5c84675807a (patch)
treee0bdd881745ca5e7fb8b6ddc1324379ff77b89ed
parent07e42e88d9f2b7756dde0a2377990ebf3c5e1973 (diff)
Share caches for short encoding ivar name.
-rw-r--r--marshal.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/marshal.c b/marshal.c
index 61c7c13..6b475aa 100644
--- a/marshal.c
+++ b/marshal.c
@@ -83,6 +83,7 @@ shortlen(size_t len, BDIGIT *ds)
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;
+static ID s_encoding_short;
#define name_s_dump "_dump"
#define name_s_load "_load"
@@ -96,6 +97,7 @@ static ID s_getbyte, s_read, s_write, s_binmode;
#define name_s_read "read"
#define name_s_write "write"
#define name_s_binmode "binmode"
+#define name_s_encoding_short "E"
typedef struct {
VALUE newclass;
@@ -559,7 +561,7 @@ w_uclass(VALUE obj, VALUE super, struct dump_arg *arg)
}
}
-#define to_be_skipped_id(id) (id == rb_id_encoding() || id == rb_intern("E") || !rb_id2str(id))
+#define to_be_skipped_id(id) (id == rb_id_encoding() || id == s_encoding_short || !rb_id2str(id))
struct w_ivar_arg {
struct dump_call_arg *dump;
@@ -634,7 +636,7 @@ w_encoding(VALUE encname, struct dump_call_arg *arg)
switch (encname) {
case Qfalse:
case Qtrue:
- w_symbol(ID2SYM(rb_intern("E")), arg->arg);
+ w_symbol(ID2SYM(s_encoding_short), arg->arg);
w_object(encname, arg->arg, limit);
return 1;
case Qnil:
@@ -2293,6 +2295,7 @@ Init_marshal(void)
set_id(s_read);
set_id(s_write);
set_id(s_binmode);
+ set_id(s_encoding_short);
rb_define_module_function(rb_mMarshal, "dump", marshal_dump, -1);
rb_define_module_function(rb_mMarshal, "load", marshal_load, -1);