From 02c32b2e9299726e20bb4499fa7c1f5430ce0b6d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 29 Nov 2020 15:01:41 +0900 Subject: Get rid of allocation when the capacity is small --- string.c | 1 + 1 file changed, 1 insertion(+) (limited to 'string.c') 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; } -- cgit v1.2.3