[llvm] 71f82bb - [SPIRV] Use heterogenous lookups with std::map (NFC) (#115425)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 8 07:33:33 PST 2024
Author: Kazu Hirata
Date: 2024-11-08T07:33:30-08:00
New Revision: 71f82bba35c48eaf98c50aeeb4d2675156681c02
URL: https://github.com/llvm/llvm-project/commit/71f82bba35c48eaf98c50aeeb4d2675156681c02
DIFF: https://github.com/llvm/llvm-project/commit/71f82bba35c48eaf98c50aeeb4d2675156681c02.diff
LOG: [SPIRV] Use heterogenous lookups with std::map (NFC) (#115425)
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
Added:
Modified:
llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index e58366017966a7..d6a59addaf2d0a 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -20,7 +20,7 @@
using namespace llvm;
-static const std::map<std::string, SPIRV::Extension::Extension>
+static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
SPIRVExtensionMap = {
{"SPV_EXT_shader_atomic_float_add",
SPIRV::Extension::Extension::SPV_EXT_shader_atomic_float_add},
@@ -98,7 +98,7 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, llvm::StringRef ArgName,
return O.error("Invalid extension list format: " + Token.str());
llvm::StringRef ExtensionName = Token.substr(1);
- auto NameValuePair = SPIRVExtensionMap.find(ExtensionName.str());
+ auto NameValuePair = SPIRVExtensionMap.find(ExtensionName);
if (NameValuePair == SPIRVExtensionMap.end())
return O.error("Unknown SPIR-V extension: " + Token.str());
More information about the llvm-commits
mailing list