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:
Daniel Tschinder 2019-01-15 23:30:46 -08:00
parent 49f7bcf271
commit 455e003567

View File

@ -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