Skip to content

Optimize var_export - #23189

Open
kamil-tekiela wants to merge 3 commits into
php:masterfrom
kamil-tekiela:Optimize-var_export
Open

Optimize var_export#23189
kamil-tekiela wants to merge 3 commits into
php:masterfrom
kamil-tekiela:Optimize-var_export

Conversation

@kamil-tekiela

Copy link
Copy Markdown
Member

The first commit replaces sprintf with memset.

The second commit replaces php_addcslashes and php_str_to_str with a custom function based on the smart_str_append_escaped function from zend_smart_str.c. At one of the 3 call sites, the php_str_to_str was 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_spaces should have inline or not. I assume it shouldn't.

In my simple round of testing, this proved to make var_export 3x faster.

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.

1 participant