Author: Kazu Hirata Date: 2024-11-06T08:35:24-08:00 New Revision: b7ee03ffb8696c4d81a5a97c61cb2149c17e6573
URL: https://github.com/llvm/llvm-project/commit/b7ee03ffb8696c4d81a5a97c61cb2149c17e6573 DIFF: https://github.com/llvm/llvm-project/commit/b7ee03ffb8696c4d81a5a97c61cb2149c17e6573.diff LOG: [clang-include-fixer] Use heterogenous lookups with std::map (NFC) (#115113) Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string. Added: Modified: clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.h Removed: ################################################################################ diff --git a/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp b/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp index 93b534d26f2ce3..6d272af7436923 100644 --- a/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp +++ b/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp @@ -21,7 +21,7 @@ InMemorySymbolIndex::InMemorySymbolIndex( std::vector<SymbolAndSignals> InMemorySymbolIndex::search(llvm::StringRef Identifier) { - auto I = LookupTable.find(std::string(Identifier)); + auto I = LookupTable.find(Identifier); if (I != LookupTable.end()) return I->second; return {}; diff --git a/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.h b/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.h index bea8be91a43c75..c91a7a3a0a10e4 100644 --- a/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.h +++ b/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.h @@ -27,7 +27,8 @@ class InMemorySymbolIndex : public SymbolIndex { search(llvm::StringRef Identifier) override; private: - std::map<std::string, std::vector<find_all_symbols::SymbolAndSignals>> + std::map<std::string, std::vector<find_all_symbols::SymbolAndSignals>, + std::less<>> LookupTable; }; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits