From ed8b452e37322e66eb94dafa36f2b5da8f5ca44a Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 29 Sep 2015 07:37:40 +0000 Subject: compile.c: fix performance of strconcat * compile.c (compile_dstr_fragments): fix performance by omitting the first empty string only for keeping literal encoding if other literals are too. [ruby-core:70930] [Bug #11556] * string.c (rb_str_append_literal): append but keep encoding non US-ASCII. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'string.c') diff --git a/string.c b/string.c index e93af5cece..728676c159 100644 --- a/string.c +++ b/string.c @@ -2460,6 +2460,18 @@ rb_str_append(VALUE str, VALUE str2) return rb_str_buf_append(str, str2); } +VALUE +rb_str_append_literal(VALUE str, VALUE str2) +{ + int encidx = rb_enc_get_index(str2); + rb_str_buf_append(str, str2); + if (encidx != ENCINDEX_US_ASCII) { + if (rb_enc_get_index(str) == ENCINDEX_US_ASCII) + rb_enc_associate_index(str, encidx); + } + return str; +} + /* * call-seq: * str << integer -> str -- cgit v1.2.3