perf: Optimize regex
This saves some steps, as the regex parser does not have to backtrack for character classes, but is has to for alternates
This commit is contained in:
parent
49f7bcf271
commit
455e003567
@ -4,7 +4,7 @@ import * as charCodes from "charcodes";
|
|||||||
|
|
||||||
// Matches a whole line break (where CRLF is considered a single
|
// Matches a whole line break (where CRLF is considered a single
|
||||||
// line break). Used to count lines.
|
// line break). Used to count lines.
|
||||||
export const lineBreak = /\r\n?|\n|\u2028|\u2029/;
|
export const lineBreak = /\r\n?|[\n\u2028\u2029]/;
|
||||||
export const lineBreakG = new RegExp(lineBreak.source, "g");
|
export const lineBreakG = new RegExp(lineBreak.source, "g");
|
||||||
|
|
||||||
// https://tc39.github.io/ecma262/#sec-line-terminators
|
// https://tc39.github.io/ecma262/#sec-line-terminators
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user