ruby-changes:65440
From: Jean <ko1@a...>
Date: Thu, 11 Mar 2021 06:44:22 +0900 (JST)
Subject: [ruby-changes:65440] d00e7deb5c (master): Use rb_enc_interned_str in ibf_load_object_string
https://git.ruby-lang.org/ruby.git/commit/?id=d00e7deb5c From d00e7deb5c780d75e4edd3afa3e26ea02c296d8c Mon Sep 17 00:00:00 2001 From: Jean Boussier <jean.boussier@g...> Date: Sat, 23 Jan 2021 10:15:22 +0100 Subject: Use rb_enc_interned_str in ibf_load_object_string --- compile.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compile.c b/compile.c index 898b02e..ce50168 100644 --- a/compile.c +++ b/compile.c @@ -11389,17 +11389,20 @@ ibf_load_object_string(const struct ibf_load *load, const struct ibf_object_head https://github.com/ruby/ruby/blob/trunk/compile.c#L11389 const long len = (long)ibf_load_small_value(load, &reading_pos); const char *ptr = load->current_buffer->buff + reading_pos; - VALUE str = rb_str_new(ptr, len); - if (encindex > RUBY_ENCINDEX_BUILTIN_MAX) { VALUE enc_name_str = ibf_load_object(load, encindex - RUBY_ENCINDEX_BUILTIN_MAX); encindex = rb_enc_find_index(RSTRING_PTR(enc_name_str)); } - rb_enc_associate_index(str, encindex); - if (header->internal) rb_obj_hide(str); - if (header->frozen) str = rb_fstring(str); + VALUE str; + if (header->frozen && !header->internal) { + str = rb_enc_interned_str(ptr, len, rb_enc_from_index(encindex)); + } else { + str = rb_enc_str_new(ptr, len, rb_enc_from_index(encindex)); + if (header->internal) rb_obj_hide(str); + if (header->frozen) str = rb_fstring(str); + } return str; } -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/