[llvm-commits] [llvm] r94860 - /llvm/trunk/utils/FileCheck/FileCheck.cpp

Daniel Dunbar daniel at zuster.org
Fri Jan 29 16:24:06 PST 2010


Author: ddunbar
Date: Fri Jan 29 18:24:06 2010
New Revision: 94860

URL: http://llvm.org/viewvc/llvm-project?rev=94860&view=rev
Log:
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.

Modified:
    llvm/trunk/utils/FileCheck/FileCheck.cpp

Modified: llvm/trunk/utils/FileCheck/FileCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/FileCheck.cpp?rev=94860&r1=94859&r2=94860&view=diff

==============================================================================
--- llvm/trunk/utils/FileCheck/FileCheck.cpp (original)
+++ llvm/trunk/utils/FileCheck/FileCheck.cpp Fri Jan 29 18:24:06 2010
@@ -340,7 +340,10 @@
   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,





More information about the llvm-commits mailing list