[前][次][番号順一覧][スレッド一覧]

ruby-changes:69955

From: Peter <ko1@a...>
Date: Sat, 27 Nov 2021 03:27:53 +0900 (JST)
Subject: [ruby-changes:69955] 7cfacbcad2 (master): Improve performance of embedded string allocation

https://git.ruby-lang.org/ruby.git/commit/?id=7cfacbcad2

From 7cfacbcad2d6bd510cf69a7b31b7ede4e293fef2 Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter@p...>
Date: Fri, 26 Nov 2021 10:33:31 -0500
Subject: Improve performance of embedded string allocation

Non-VWA embedded string allocation had a performance regression. This
commit improves performance of non-VWA embedded string allocation.
---
 string.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/string.c b/string.c
index 82011244095..303cd9b98b8 100644
--- a/string.c
+++ b/string.c
@@ -1739,7 +1739,6 @@ str_duplicate_setup(VALUE klass, VALUE str, VALUE dup) https://github.com/ruby/ruby/blob/trunk/string.c#L1739
         assert(str_embed_capa(dup) >= len + 1);
         STR_SET_EMBED_LEN(dup, len);
         MEMCPY(RSTRING(dup)->as.embed.ary, RSTRING(str)->as.embed.ary, char, len + 1);
-        flags &= ~RSTRING_NOEMBED;
     }
     else {
         VALUE root = str;
@@ -1781,7 +1780,7 @@ static inline VALUE https://github.com/ruby/ruby/blob/trunk/string.c#L1780
 ec_str_duplicate(struct rb_execution_context_struct *ec, VALUE klass, VALUE str)
 {
     VALUE dup;
-    if (FL_TEST(str, STR_NOEMBED)) {
+    if (!USE_RVARGC || FL_TEST(str, STR_NOEMBED)) {
         dup = ec_str_alloc_heap(ec, klass);
     }
     else {
@@ -1795,7 +1794,7 @@ static inline VALUE https://github.com/ruby/ruby/blob/trunk/string.c#L1794
 str_duplicate(VALUE klass, VALUE str)
 {
     VALUE dup;
-    if (FL_TEST(str, STR_NOEMBED)) {
+    if (!USE_RVARGC || FL_TEST(str, STR_NOEMBED)) {
         dup = str_alloc_heap(klass);
     }
     else {
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]