Skip to content

Commit 155a154

Browse files
perf(css,html): cut allocation and scanning in the printers, output unchanged
Profile-driven changes to the CSS and HTML printers: - tokenizer: skip whitespace at the sites that discard it, and read the namespace prologue and light-dark() presence with a scan, not a regex - parser: resolve the target selection once, and only where one is set - walk: rule entries by node id in a column instead of a Map cleared per top-level node; substitution checks look behind each `(` in place - printer: numeric tokens hand back the text they were given, cheap character gates before calc()/zero-unit/color regexes, box longhands merged without an entry pair or a Set per rule, and a custom property's tokens read where they lie rather than through a fresh array - html: a `<li>` scan stops at a list-item scope boundary, and a document with no caller's renderer and no `srcdoc` prints synchronously - source maps: the map walks the flat output once, and retractable mappings sit in an array Measured against 9cb49ef over the ecosystem stylesheets: self time in lib/css/syntax.js is lower in each of three cpu-profile pairs, median 95.9% of baseline. Wall time over the same fixtures stays inside the run-to-run spread (99.5%, n=9) and GC events per pass are unchanged at 34.2, so the win is a few percent of the CSS minifier, not more. Output is byte-identical over the 34 ecosystem fixtures and the 564 css/html config-case snapshots.
1 parent 9cb49ef commit 155a154

6 files changed

Lines changed: 443 additions & 201 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Cut allocation and scanning in the CSS and HTML printers, output unchanged.

0 commit comments

Comments
 (0)