Simplify or optimize regexes with polynomial time worst cases (#44197)

* Simplify or optimize regexes with polynomial time worst cases

* PR feedback & cleanup

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>

* Use builtin scanner function for checking whitespace in fallback method (its faster)

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>
This commit is contained in:
Wesley WighamandDavid Michon authored and GitHub committed 2021-05-24 15:28:52 -07:00
1 parent 2203228b62
commit fcabb5c0cc
11 files changed
+158 -85

No files matched your search

+1 -1
View File
@@ -406,7 +406,7 @@ namespace ts {
const lineStart = getPositionOfLineAndCharacter(file, i, 0);
const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
let lineContent = file.text.slice(lineStart, lineEnd);
lineContent = lineContent.replace(/\s+$/g, ""); // trim from end
lineContent = trimStringEnd(lineContent); // trim from end
lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces
// Output the gutter and the actual contents of the line.