From 8cdf54c222e911f09b57ab0d8fdd3408979df91b Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 29 Jan 2010 03:22:19 +0000 Subject: 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 --- utils/FileCheck/FileCheck.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'utils/FileCheck') diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp index 078028a115..440d7d741b 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, -- cgit v1.2.3-18-g5258