Skip to content

ext/json: Remove unnecessary smart_str_alloc() before smart_str_appendc()#21435

Closed
arshidkv12 wants to merge 1 commit intophp:masterfrom
arshidkv12:json_buf
Closed

ext/json: Remove unnecessary smart_str_alloc() before smart_str_appendc()#21435
arshidkv12 wants to merge 1 commit intophp:masterfrom
arshidkv12:json_buf

Conversation

@arshidkv12
Copy link
Contributor

@arshidkv12 arshidkv12 commented Mar 14, 2026

No description provided.

checkpoint = buf->s ? ZSTR_LEN(buf->s) : 0;

/* pre-allocate for string length plus 2 quotes */
smart_str_alloc(buf, len+2, 0);
Copy link
Member

@devnexen devnexen Mar 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line might be more useful than you think (i.e. upfront little optim). edit: well the comment just above says so..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not recommend to merge it, but if bukka thinks it's good I won't argue :)

@ndossche
Copy link
Member

No, this is needed to avoid continuous reallocations of the string buffer.

@ndossche ndossche closed this Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants