From 53df522a0c536d32a60c0ed571097a78ce2541a7 Mon Sep 17 00:00:00 2001 From: Nathan James Date: Mon, 3 May 2021 11:20:20 +0100 Subject: [PATCH] [clang-tidy][NFC] Short circuit getting enum options suggestions. Use the MaxEditDistance to skip checking candidates we know we'll skip. --- clang-tools-extra/clang-tidy/ClangTidyCheck.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index 46b69ed538cb..6f7f6611c8d2 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -147,7 +147,7 @@ llvm::Optional 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 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;