diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-01-29 03:22:19 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-01-29 03:22:19 +0000 |
commit | 8cdf54c222e911f09b57ab0d8fdd3408979df91b (patch) | |
tree | 39e1d60bd53ced9933b25680e3bee16cc902efde /utils | |
parent | 407e47c21ea201292adf978e06d6b7c1dc62cda9 (diff) | |
download | external_llvm-8cdf54c222e911f09b57ab0d8fdd3408979df91b.zip external_llvm-8cdf54c222e911f09b57ab0d8fdd3408979df91b.tar.gz external_llvm-8cdf54c222e911f09b57ab0d8fdd3408979df91b.tar.bz2 |
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
Diffstat (limited to 'utils')
-rw-r--r-- | utils/FileCheck/FileCheck.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp index 078028a..440d7d7 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, |