perf: inline is_ident_char() in hot tokenizer loops via CHAR_IDENT bi…#149
Merged
bartveneman merged 1 commit intomainfrom Feb 26, 2026
Merged
perf: inline is_ident_char() in hot tokenizer loops via CHAR_IDENT bi…#149bartveneman merged 1 commit intomainfrom
bartveneman merged 1 commit intomainfrom
Conversation
…tmask Add CHAR_IDENT (1 << 5) to the lookup table and replace all 4 is_ident_char() callsites in tight loops with a direct bitmask check, eliminating the 3-function call chain (is_ident_char → is_ident_start → is_alpha) on every character scanned. Benchmark results vs main: - Tokenizer - Large CSS: 29,920 → 32,064 ops/sec (+7.2%) - Tokenizer - Bootstrap CSS: 356 → 401 ops/sec (+12.6%) - Tokenizer - Tailwind CSS: 28 → 31 ops/sec (+10.7%) - Parser - Large CSS: 18,801 → 19,908 ops/sec (+5.9%) - Parser - Bootstrap CSS: 231 → 244 ops/sec (+5.6%) - Parser - Tailwind CSS: 17 → 18 ops/sec (+5.9%) - Parse/walk - Bootstrap CSS: 204 → 215 ops/sec (+5.4%) - Parse/walk - Tailwind CSS: 15 → 16 ops/sec (+6.7%) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bundle ReportChanges will increase total bundle size by 235 bytes (0.16%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: @projectwallace/css-parser-esmAssets Changed:
Files in
Files in
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #149 +/- ##
==========================================
- Coverage 94.87% 94.71% -0.17%
==========================================
Files 16 16
Lines 2714 2726 +12
Branches 712 713 +1
==========================================
+ Hits 2575 2582 +7
- Misses 139 144 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
…tmask
Add CHAR_IDENT (1 << 5) to the lookup table and replace all 4 is_ident_char() callsites in tight loops with a direct bitmask check, eliminating the 3-function call chain (is_ident_char → is_ident_start → is_alpha) on every character scanned.
Benchmark results vs main: