Skip to content

CSS API: Decode an identifier only when a url token may follow - #107

Open
sirreal wants to merge 2 commits into
css-api/css-token-processor-foundationsfrom
css-api/tokenizer-url-check-order
Open

sirreal wants to merge 2 commits into
css-api/css-token-processor-foundationsfrom
css-api/tokenizer-url-check-order

Conversation

@sirreal

@sirreal sirreal commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Caution

This is a work in progress draft and is not ready for any serious review.

Check for ( before decoding an identifier in consume_ident_like(). The identifier is compared with url only to decide whether a url token follows, which needs ( as the next byte. Most identifiers are not followed by (, so the decoding is skipped for them.

No behavior changes. The css-api group passes (1007 tests).

Tokenizing 257 KB of CSS (buttons.css, admin-bar.css, dashicons.css and Twenty Twenty-One's style.css, 51,336 tokens) takes 17.1 ms instead of 18.9 ms: best of 15 runs, one process per variant, three rounds, PHP 8.5. The commit message's numbers and its reference to a previous commit come from a 70 KB stylesheet on the branch where the change was first written; this PR stands alone.

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.

consume_ident_like() decoded every identifier to compare it with
"url", and used the result only when the next byte is `(`. Checking
that byte first skips the decoding for every identifier that is not
followed by `(`, which is most of them.

Tokenizing the 70 KB stylesheet from the previous commit took 4.9 ms
before and 4.5 ms after, best of 10 runs on PHP 8.5.

(cherry picked from commit a72493d)
@github-actions

Copy link
Copy Markdown

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:

Props jonsurrell.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant