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

ruby-changes:63793

From: Nobuyoshi <ko1@a...>
Date: Sun, 29 Nov 2020 21:25:20 +0900 (JST)
Subject: [ruby-changes:63793] 02c32b2e92 (master): Get rid of allocation when the capacity is small

https://git.ruby-lang.org/ruby.git/commit/?id=02c32b2e92

From 02c32b2e9299726e20bb4499fa7c1f5430ce0b6d Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 29 Nov 2020 15:01:41 +0900
Subject: Get rid of allocation when the capacity is small


diff --git a/string.c b/string.c
index 6abfcd3..b33d83c 100644
--- a/string.c
+++ b/string.c
@@ -1351,6 +1351,7 @@ rb_str_buf_new(long capa) https://github.com/ruby/ruby/blob/trunk/string.c#L1351
 {
     VALUE str = str_alloc(rb_cString);
 
+    if (capa <= RSTRING_EMBED_LEN_MAX) return str;
     if (capa < STR_BUF_MIN_SIZE) {
 	capa = STR_BUF_MIN_SIZE;
     }
-- 
cgit v0.10.2


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

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