Optimize var_export - #23189
Open
kamil-tekiela wants to merge 3 commits into
Open
Conversation
Based on smart_str_append_escaped
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first commit replaces
sprintfwithmemset.The second commit replaces
php_addcslashesandphp_str_to_strwith a custom function based on thesmart_str_append_escapedfunction from zend_smart_str.c. At one of the 3 call sites, thephp_str_to_strwas absent, and I didn't know what to do, which is why I added the flag. This makes the most sense to me, but I could also make it separate from the new function.I don't know whether
buffer_append_spacesshould haveinlineor not. I assume it shouldn't.In my simple round of testing, this proved to make
var_export3x faster.