[llvm] [Support] Avoid repeated hash lookups (NFC) (PR #123503)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 18 22:22:07 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/123503.diff
1 Files Affected:
- (modified) llvm/lib/Support/VirtualFileSystem.cpp (+3-2)
``````````diff
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 5febdf992fbfee..e489282281d269 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -1708,11 +1708,12 @@ class llvm::vfs::RedirectingFileSystemParser {
// false on error
bool checkDuplicateOrUnknownKey(yaml::Node *KeyNode, StringRef Key,
DenseMap<StringRef, KeyStatus> &Keys) {
- if (!Keys.count(Key)) {
+ auto It = Keys.find(Key);
+ if (It == Keys.end()) {
error(KeyNode, "unknown key");
return false;
}
- KeyStatus &S = Keys[Key];
+ KeyStatus &S = It->second;
if (S.Seen) {
error(KeyNode, Twine("duplicate key '") + Key + "'");
return false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/123503
More information about the llvm-commits
mailing list