Repository navigation
Conversation
consume_ident_sequence() scans ASCII name bytes with strspn() and then asks consume_ident_start_codepoint() about the byte that stopped the scan. For an ASCII byte such as `,` `:` or a space, that method ran _wp_scan_utf8() and utf8_ord() before returning 0. An ASCII byte other than a letter, `_` or NUL never starts an identifier, so the method returns 0 for it before decoding. Tokenizing a 70 KB stylesheet (a generated global stylesheet with the admin-bar and buttons styles, 15,979 tokens) took 6.2 ms before and 4.9 ms after, best of 10 runs on PHP 8.5. (cherry picked from commit 0dab3d9)
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
…okenizer-ascii-ident-start
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.
Caution
This is a work in progress draft and is not ready for any serious review.
Return early from
consume_ident_start_codepoint()for ASCII bytes that cannot start an identifier. The method runs after every identifier on the byte that ends it, usually:,,,;,(or a space. For those bytes it ran_wp_scan_utf8()andutf8_ord()before returning 0. An ASCII byte other than a letter,_or NUL never starts an identifier, so the method now returns 0 before it decodes.No behavior changes. The
css-apigroup passes (1007 tests).Tokenizing 257 KB of CSS (
buttons.css,admin-bar.css,dashicons.cssand Twenty Twenty-One'sstyle.css, 51,336 tokens) takes 15.2 ms instead of 18.9 ms: best of 15 runs, one process per variant, three rounds, PHP 8.5.Depends on WordPress#14781.
Trac ticket: TBD
Use of AI Tools
AI assistance: Yes
Tools: Claude Code
Models: Claude Opus 5.5
Used for: implementation, measurement and this description.
This pull request is for code review only. Keep other discussion in the Trac ticket. Do not merge. See GitHub Pull Requests for Code Review in the Core Handbook.