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
This commit is contained in:
Daniel Dunbar 2010-01-30 00:24:06 +00:00
parent a97adee959
commit e9aa36c895
1 changed files with 4 additions and 1 deletions

View File

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