[llvm] [Support] Avoid repeated hash lookups (NFC) (PR #123503)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 18 22:21:32 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/123503
None
>From 55fdd68058488e8524c07b83030c676a54abd6b9 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 18 Jan 2025 10:09:09 -0800
Subject: [PATCH] [Support] Avoid repeated hash lookups (NFC)
---
llvm/lib/Support/VirtualFileSystem.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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;
More information about the llvm-commits
mailing list