wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

HTML API: Replace associative array for tracking parsed attributes.

Open dmsnell opened this issue 2 years ago • 2 comments

Trac Ticket: Core-61545

Experimenting to determine if we have any measurable performance overhead in the associate array that previously stored parsed attribute tokens.

From:

$this->attributes[ $attribute_name ] = $token;

To:

$this->attributes[] = $token;

Previously we also tracked duplicate attributes so that we could remove them on remove_attribute() but in this case, we don't perform any determination for duplicate attributes until removing an attribute. This is because the first attribute (the one with the value) will appear first in the list of parsed attributes, and we can ignore the rest.

Performance testing

In every case this has been improving the speed of the Tag Processor by between 3% and 5%. Unfortunately I'm unable to upload images right now due to my internet connection, but I've tried with the single-page.html document that is the 12 MB spec document and the demo-post.html from Gutenberg and the results are consistent.

All tests use marginally less memory as well, but the total memory usage is less than 2 KB so it's hardly a gain 🙃

dmsnell avatar Dec 16 '23 12:12 dmsnell