This revision was automatically updated to reflect the committed changes. Closed by commit rG79353f940cf4: [clang-tidy][NFC] Remove Tristate from CachedGlobList (authored by njames93).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120196/new/ https://reviews.llvm.org/D120196 Files: clang-tools-extra/clang-tidy/GlobList.cpp clang-tools-extra/clang-tidy/GlobList.h Index: clang-tools-extra/clang-tidy/GlobList.h =================================================================== --- clang-tools-extra/clang-tidy/GlobList.h +++ clang-tools-extra/clang-tidy/GlobList.h @@ -59,8 +59,7 @@ bool contains(StringRef S) const override; private: - enum Tristate { None, Yes, No }; - mutable llvm::StringMap<Tristate> Cache; + mutable llvm::StringMap<bool> Cache; }; } // namespace tidy Index: clang-tools-extra/clang-tidy/GlobList.cpp =================================================================== --- clang-tools-extra/clang-tidy/GlobList.cpp +++ clang-tools-extra/clang-tidy/GlobList.cpp @@ -65,16 +65,12 @@ } bool CachedGlobList::contains(StringRef S) const { - switch (auto &Result = Cache[S]) { - case Yes: - return true; - case No: - return false; - case None: - Result = GlobList::contains(S) ? Yes : No; - return Result == Yes; - } - llvm_unreachable("invalid enum"); + auto Entry = Cache.try_emplace(S); + bool &Value = Entry.first->getValue(); + // If the entry was just inserted, determine its required value. + if (Entry.second) + Value = GlobList::contains(S); + return Value; } } // namespace tidy
Index: clang-tools-extra/clang-tidy/GlobList.h =================================================================== --- clang-tools-extra/clang-tidy/GlobList.h +++ clang-tools-extra/clang-tidy/GlobList.h @@ -59,8 +59,7 @@ bool contains(StringRef S) const override; private: - enum Tristate { None, Yes, No }; - mutable llvm::StringMap<Tristate> Cache; + mutable llvm::StringMap<bool> Cache; }; } // namespace tidy Index: clang-tools-extra/clang-tidy/GlobList.cpp =================================================================== --- clang-tools-extra/clang-tidy/GlobList.cpp +++ clang-tools-extra/clang-tidy/GlobList.cpp @@ -65,16 +65,12 @@ } bool CachedGlobList::contains(StringRef S) const { - switch (auto &Result = Cache[S]) { - case Yes: - return true; - case No: - return false; - case None: - Result = GlobList::contains(S) ? Yes : No; - return Result == Yes; - } - llvm_unreachable("invalid enum"); + auto Entry = Cache.try_emplace(S); + bool &Value = Entry.first->getValue(); + // If the entry was just inserted, determine its required value. + if (Entry.second) + Value = GlobList::contains(S); + return Value; } } // namespace tidy
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits