Repository navigation
perf(rules): one-pass scan in legal/cookie-consent, no lowercase copy in social/share-buttons #270 - #1008
Merged
Conversation
|
Reviewed the diff and tests by reading only; I did not run the tests or check CI. No blocking issues found.
The share-buttons guard for U+212A and U+0130 looks correct and is well covered by the exhaustive test. The benchmark notes and changelog entry are clear. Co-Authored-By: Claude Sonnet 5.5 [email protected] |
… in social/share-buttons #270 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
perf/270-rules-phase-hotspots
branch
from
October 22, 2026 01:43
f939973 to
115aeb4
Compare
|
Review of #1008 (single-pass scan for legal/cookie-consent, un-lowercased patterns for social/share-buttons). I read the diff only and did not run the tests.
Otherwise the early return on a container hit is safe because regions is unused in that case. The Kelvin sign and U+0130 fallback in share-buttons looks correct, and the exhaustive BMP test covers it well. The benchmark write-up is clear. |
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.
Closes #270
What
legal/cookie-consent: the 21querySelectorand 7querySelectorAllfull-document sweeps become one pass over the elements. The predicates are the selector engine's own: id compared verbatim, class by whole whitespace-delimited token (both case-sensitive),cookie/consentby case-insensitive RegExp on the raw attribute,role/aria-modalexact.social/share-buttons: the four/ipatterns are tested on the raw page instead ofhtml.toLowerCase(). The two differ only wheretoLowerCase()produces an ASCII letter from a non-ASCII one (U+212A Kelvin sign, U+0130), so a page containing either keeps the lowercased path. Answers are unchanged, so no decision is needed on the divergence.Numbers
Rule-level bench on a generated 1.03 MB script-heavy page (59 inline scripts, 1,500 cards), 60
run()calls after warm-up, base and branch alternating, 5 rounds, medians, isolated HOME, wall time:legal/cookie-consentsocial/share-buttonsThe original 1.13 MB fixture is not in the repo, so these are not comparable to the 8.2 / 6.4 ms in the issue. Results of both rules are byte-identical on the fixture. Row added to
benchmarks/2026-09-perf-program.md.share-buttonsis mostly its four regexes now; the saving there is the lowercase copy.Parity
packages/rules/tests/cookie-share-single-pass-270.test.ts: 2,000 randomised pages (case variants, tab/NBSP/newline class separators, Kelvin sign) compared against the verbatim old selector logic; every BMP character spliced into each share pattern compared against the lowercase version. Both mutation-checked (dropping the Kelvin fallback and making the cookie regex case-sensitive each fail the suite).cookie-consent-detection.test.tspasses.tsgo --noEmitclean in packages/rules.Docs and skill
No docs change (no behaviour change). Agent skill: no change needed.