[llvm] [SPIRV] Use heterogenous lookups with std::map (NFC) (PR #115425)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 22:31:47 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
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/115425.diff
1 Files Affected:
- (modified) llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp (+2-2)
``````````diff
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());
``````````
</details>
https://github.com/llvm/llvm-project/pull/115425
More information about the llvm-commits
mailing list