Skip to content

Commit 5d53e4c

Browse files
Don't use capturing groups during default preprocessing
We aren't using backreferences during default preprocessing, so we don't need to capture any groups. Signed-off-by: David A. Wheeler <[email protected]>
1 parent 7abc936 commit 5d53e4c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/labs/checker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ let preprocessRegexes = [
4141
[/[ \t]+\\s\+[ \t]+/g, '\\s+'],
4242

4343
// 1+ spaces/tabs are instead interpreted as \s* (0+ whitespace)
44-
// The (\\s\*)? expressions before and after it are an optimization -
44+
// The (?:\\s\*)? expressions before and after it are an optimization -
4545
// if you use \s* next to spaces/tabs, they coalesce for speed.
46-
[/(\\s\*)?[ \t]+(\\s\*)?/g, '\\s*']
46+
// We use non-capturing groups (?:...) for speed. Preprocessing is only
47+
// done once on startup, so speed isn't important, but it's often good
48+
// to avoid capturing groups when you don't need to.
49+
[/(?:\\s\*)?[ \t]+(?:\\s\*)?/g, '\\s*']
4750
];
4851

4952
/**

0 commit comments

Comments
 (0)