Get rid of allocation when the capacity is small

This commit is contained in:
Nobuyoshi Nakada 2020-11-29 15:01:41 +09:00
parent 9c5d1a2964
commit 02c32b2e92
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

View File

@ -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;
}