Get rid of allocation when the capacity is small
This commit is contained in:
parent
9c5d1a2964
commit
02c32b2e92
1
string.c
1
string.c
@ -1351,6 +1351,7 @@ rb_str_buf_new(long capa)
|
|||||||
{
|
{
|
||||||
VALUE str = str_alloc(rb_cString);
|
VALUE str = str_alloc(rb_cString);
|
||||||
|
|
||||||
|
if (capa <= RSTRING_EMBED_LEN_MAX) return str;
|
||||||
if (capa < STR_BUF_MIN_SIZE) {
|
if (capa < STR_BUF_MIN_SIZE) {
|
||||||
capa = STR_BUF_MIN_SIZE;
|
capa = STR_BUF_MIN_SIZE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user