aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-11-29 15:01:41 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-11-29 15:01:41 +0900
commit02c32b2e9299726e20bb4499fa7c1f5430ce0b6d (patch)
tree3474373a4cbbe472e70c32657789d2f6327c0de2 /string.c
parent9c5d1a2964fb310f7ac024d74fa286e36f24ad49 (diff)
downloadruby-02c32b2e9299726e20bb4499fa7c1f5430ce0b6d.tar.gz
Get rid of allocation when the capacity is small
Diffstat (limited to 'string.c')
-rw-r--r--string.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/string.c b/string.c
index 6abfcd33f8..b33d83caaf 100644
--- a/string.c
+++ b/string.c
@@ -1351,6 +1351,7 @@ rb_str_buf_new(long capa)
{
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;
}