From 5cc772b8aa1a57ccbb7d2b875e011f208dce20df Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Tue, 30 Mar 2021 16:58:11 +0000 Subject: [PATCH] Optimize static error test file parsing. For some reason, the regexp to strip off multitest comments was very slow. On a couple of co_19 tests with pathologically long lines, it would hang practically forever. Even on shorter lines, it was noticeably slow. This fixes that. Change-Id: I04f2894f474dcc593e982dd691945421396274a6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193222 Auto-Submit: Bob Nystrom Commit-Queue: Paul Berry Reviewed-by: Paul Berry --- pkg/test_runner/lib/src/static_error.dart | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/test_runner/lib/src/static_error.dart b/pkg/test_runner/lib/src/static_error.dart index 22c8a212e57..d8ede3a7082 100644 --- a/pkg/test_runner/lib/src/static_error.dart +++ b/pkg/test_runner/lib/src/static_error.dart @@ -392,9 +392,6 @@ class _ErrorExpectationParser { /// are part of it. static final _errorMessageRestRegExp = RegExp(r"^\s*//\s*(.*)"); - /// Matches the multitest marker and yields the preceding content. - final _stripMultitestRegExp = RegExp(r"(.*)//#"); - final List _lines; final List _errors = []; int _currentLine = 0; @@ -524,9 +521,9 @@ class _ErrorExpectationParser { var line = _lines[_currentLine + offset]; // Strip off any multitest marker. - var multitestMatch = _stripMultitestRegExp.firstMatch(line); - if (multitestMatch != null) { - line = multitestMatch.group(1).trimRight(); + var index = line.indexOf("//#"); + if (index != -1) { + line = line.substring(0, index).trimRight(); } return line;