summaryrefslogtreecommitdiffstats
path: root/llvm/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
commite9aa36c8951e9f95aaa1dcc7ef0a9e277f006dfb (patch)
treee0b182beb5522612cd854e6e8e7af1eee321e015 /llvm/utils/FileCheck
parenta97adee959825613fe295e1bbc6bc914edb5c4ca (diff)
downloadbcm5719-llvm-e9aa36c8951e9f95aaa1dcc7ef0a9e277f006dfb.tar.gz
bcm5719-llvm-e9aa36c8951e9f95aaa1dcc7ef0a9e277f006dfb.zip
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. llvm-svn: 94860
Diffstat (limited to 'llvm/utils/FileCheck')
-rw-r--r--llvm/utils/FileCheck/FileCheck.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 9619f945aac..3c4742cc36f 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/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,
OpenPOWER on IntegriCloud