1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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