[clang-tidy][NFC] Short circuit getting enum options suggestions.

Use the MaxEditDistance to skip checking candidates we know we'll skip.
This commit is contained in:
Nathan James 2021-05-03 11:20:20 +01:00
parent d23e4f6872
commit 53df522a0c
1 changed files with 3 additions and 2 deletions

View File

@ -147,7 +147,7 @@ llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
StringRef Value = Iter->getValue().Value;
StringRef Closest;
unsigned EditDistance = -1;
unsigned EditDistance = 3;
for (const auto &NameAndEnum : Mapping) {
if (IgnoreCase) {
if (Value.equals_lower(NameAndEnum.second))
@ -159,7 +159,8 @@ llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
EditDistance = 0;
continue;
}
unsigned Distance = Value.edit_distance(NameAndEnum.second);
unsigned Distance =
Value.edit_distance(NameAndEnum.second, true, EditDistance);
if (Distance < EditDistance) {
EditDistance = Distance;
Closest = NameAndEnum.second;