ruby-changes:56902
From: Nobuyoshi <ko1@a...>
Date: Sat, 10 Aug 2019 11:43:09 +0900 (JST)
Subject: [ruby-changes:56902] Nobuyoshi Nakada: ab31693af1 (master): Share caches for short encoding ivar name.
https://git.ruby-lang.org/ruby.git/commit/?id=ab31693af1 From ab31693af109022ecc0a01107067d5c84675807a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 10 Aug 2019 11:38:49 +0900 Subject: Share caches for short encoding ivar name. 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) https://github.com/ruby/ruby/blob/trunk/marshal.c#L83 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; https://github.com/ruby/ruby/blob/trunk/marshal.c#L97 #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) https://github.com/ruby/ruby/blob/trunk/marshal.c#L561 } } -#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) https://github.com/ruby/ruby/blob/trunk/marshal.c#L636 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) https://github.com/ruby/ruby/blob/trunk/marshal.c#L2295 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); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/