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:
parent
9c5d1a2964
commit
02c32b2e92
1 changed files with 1 additions and 0 deletions
1
string.c
1
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue