llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Kazu Hirata (kazutakahirata) <details> <summary>Changes</summary> Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string. --- Full diff: https://github.com/llvm/llvm-project/pull/115113.diff 2 Files Affected: - (modified) clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp (+1-1) - (modified) clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.h (+2-1) ``````````diff 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; }; `````````` </details> https://github.com/llvm/llvm-project/pull/115113 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits