From: Daniel Dunbar Date: Fri, 29 Jan 2010 03:22:19 +0000 (+0000) Subject: FileCheck: Switch "possible match" calculation to use StringRef::edit_distance. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8cdf54c222e911f09b57ab0d8fdd3408979df91b;p=oota-llvm.git FileCheck: Switch "possible match" calculation to use StringRef::edit_distance. - Thanks Doug, who is obviously less lazy than me! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94795 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp index 078028a115c..440d7d741ba 100644 --- a/utils/FileCheck/FileCheck.cpp +++ b/utils/FileCheck/FileCheck.cpp @@ -340,12 +340,7 @@ unsigned Pattern::ComputeMatchDistance(StringRef Buffer, if (ExampleString.empty()) ExampleString = RegExStr; - unsigned Distance = 0; - for (unsigned i = 0, e = ExampleString.size(); i != e; ++i) - if (Buffer.substr(i, 1) != ExampleString.substr(i, 1)) - ++Distance; - - return Distance; + return Buffer.substr(0, ExampleString.size()).edit_distance(ExampleString); } void Pattern::PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,