Skip to content

[regexp] Faster case closure computation - #505

Merged
Hans-Halverson merged 1 commit into
masterfrom
regexp-faster-case-closure
Aug 23, 2026
Merged

[regexp] Faster case closure computation#505
Hans-Halverson merged 1 commit into
masterfrom
regexp-faster-case-closure

Conversation

@Hans-Halverson

@Hans-Halverson Hans-Halverson commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Summary

Computing the case closure of a set of code points is currently extremely slow since we compute the case closure for each code point in that set, which may be very large (e.g. consider \D). We can speed this up by only computing the case closure for the subset of code points that actually has a case closure containing any other code points, which only applies to a much smaller set of code points than the full range. Precompute this set (for both unicode and non-unicode modes) at build time, then use it for more efficient case closure construction. The same technique can be done in MaybeSimpleCaseFolding in case insensitive unicode sets mode.

Provides a significant speedup anywhere case insensitive mode is used with large code point sets. For example "regression/000026.js" which is executing just a handful of RegExps speeds up from to 0.861 to 0.006 seconds.

Tests

  • CI

@Hans-Halverson
Hans-Halverson merged commit e1a6156 into master Aug 23, 2026
11 checks passed
@Hans-Halverson
Hans-Halverson deleted the regexp-faster-case-closure branch August 23, 2026 17:06
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