aboutsummaryrefslogtreecommitdiffstats
path: root/utils/FileCheck
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-01-30 00:24:06 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-01-30 00:24:06 +0000
commit0806f9ff5860ce351540ff2897dec1667154ca19 (patch)
tree57540ce902d350ecd819ff4e79f9b0a1217815d2 /utils/FileCheck
parentec2b1f1beb134872aba4faf2e7a9c7eabcf64df9 (diff)
downloadexternal_llvm-0806f9ff5860ce351540ff2897dec1667154ca19.zip
external_llvm-0806f9ff5860ce351540ff2897dec1667154ca19.tar.gz
external_llvm-0806f9ff5860ce351540ff2897dec1667154ca19.tar.bz2
FileCheck: When looking for "possible matches", only compare against the prefix
line. Turns out edit_distance can be slow if the string we are scanning for happens to be quite large. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/FileCheck')
-rw-r--r--utils/FileCheck/FileCheck.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp
index 9619f94..3c4742c 100644
--- a/utils/FileCheck/FileCheck.cpp
+++ b/utils/FileCheck/FileCheck.cpp
@@ -340,7 +340,10 @@ unsigned Pattern::ComputeMatchDistance(StringRef Buffer,
if (ExampleString.empty())
ExampleString = RegExStr;
- return Buffer.substr(0, ExampleString.size()).edit_distance(ExampleString);
+ // Only compare up to the first line in the buffer, or the string size.
+ StringRef BufferPrefix = Buffer.substr(0, ExampleString.size());
+ BufferPrefix = BufferPrefix.split('\n').first;
+ return BufferPrefix.edit_distance(ExampleString);
}
void Pattern::PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,