HTML API: Hoist strlen() out of the class_list() loop condition - #12964
HTML API: Hoist strlen() out of the class_list() loop condition#12964mukeshpanchal27 wants to merge 1 commit into
strlen() out of the class_list() loop condition#12964Conversation
`$class` is a local string that is never reassigned inside the loop, yet `strlen()` was called twice per iteration: once to evaluate the `while` condition and once more to check whether skipping boundary characters ran past the end. Compute the length once before the loop instead, matching the idiom already used elsewhere in core. Follow-up to [63171]. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
I recall this coming up before, that |
|
I've also heard that from @dmsnell several times and decided to verify it myself, or at least have Copilot verify it. It says:
Previously, we'd relied on this extensively across the HTML API instead of using |
Trac ticket: https://core.trac.wordpress.org/ticket/65846
Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Opus 5
Used for: Initial code skeleton; final implementation was reviewed and edited by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.