summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-12 19:29:18 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-12 19:58:22 +0900
commitbdf3032e3542b318c6f52dbe20d1c97cca3d7067 (patch)
tree6923498ebb1907e78207edaad7f2e143e0fc31ee /string.c
parent1b219f1fb26d15d69d4a0cb628f856f6f850eac5 (diff)
Make temporary lock string encoding free
As a temporary lock string is hidden, it can not have instance variables, including non-inlined encoding index.
Diffstat (limited to 'string.c')
-rw-r--r--string.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/string.c b/string.c
index 12f5d014f4..83c4780983 100644
--- a/string.c
+++ b/string.c
@@ -199,6 +199,7 @@ VALUE rb_cSymbol;
static VALUE str_replace_shared_without_enc(VALUE str2, VALUE str);
static VALUE str_new_shared(VALUE klass, VALUE str);
static VALUE str_new_frozen(VALUE klass, VALUE orig);
+static VALUE str_new_frozen_buffer(VALUE klass, VALUE orig, int copy_encoding);
static VALUE str_new_static(VALUE klass, const char *ptr, long len, int encindex);
static void str_make_independent_expand(VALUE str, long len, long expand, const int termlen);
static inline void str_modifiable(VALUE str);
@@ -1225,7 +1226,7 @@ VALUE
rb_str_tmp_frozen_acquire(VALUE orig)
{
if (OBJ_FROZEN_RAW(orig)) return orig;
- return str_new_frozen(0, orig);
+ return str_new_frozen_buffer(0, orig, FALSE);
}
void
@@ -1257,6 +1258,12 @@ rb_str_tmp_frozen_release(VALUE orig, VALUE tmp)
static VALUE
str_new_frozen(VALUE klass, VALUE orig)
{
+ return str_new_frozen_buffer(klass, orig, TRUE);
+}
+
+static VALUE
+str_new_frozen_buffer(VALUE klass, VALUE orig, int copy_encoding)
+{
VALUE str;
if (STR_EMBED_P(orig)) {
@@ -1304,7 +1311,7 @@ str_new_frozen(VALUE klass, VALUE orig)
}
}
- rb_enc_cr_str_exact_copy(str, orig);
+ if (copy_encoding) rb_enc_cr_str_exact_copy(str, orig);
OBJ_FREEZE(str);
return str;
}