From 0dd6f020fcffd26cb89ee9eda59b15483e160f45 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 31 Jan 2020 14:24:07 +0900 Subject: [PATCH] Make `empty_string` a fake string --- string.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/string.c b/string.c index 4ae804b83c..9088cec03d 100644 --- a/string.c +++ b/string.c @@ -215,7 +215,13 @@ str_make_independent(VALUE str) /* symbols for [up|down|swap]case/capitalize options */ static VALUE sym_ascii, sym_turkic, sym_lithuanian, sym_fold; -static VALUE empty_string; +static const struct RString empty_fake_string = { + { + T_STRING | STR_FAKESTR | + ENC_CODERANGE_7BIT | (ENCINDEX_US_ASCII << ENCODING_SHIFT) + } +}; +#define empty_string ((VALUE)&empty_fake_string) static rb_encoding * get_actual_encoding(const int encidx, VALUE str) @@ -4885,16 +4891,13 @@ rb_str_slice_bang(int argc, VALUE *argv, VALUE str) { VALUE result; VALUE buf[3]; - int i; rb_check_arity(argc, 1, 2); - for (i=0; i