aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-01-19 10:58:49 -0800
committerGitHub <noreply@github.com>2025-01-19 10:58:49 -0800
commit2a4c484739b313431b41e5094cfcd021284bbece (patch)
treec5e2892dc524bd04efbe568ee920c249e41e4e24 /llvm/lib/Support/VirtualFileSystem.cpp
parent24892b868199ce67bcab60d91a58e13beba6a258 (diff)
downloadllvm-2a4c484739b313431b41e5094cfcd021284bbece.zip
llvm-2a4c484739b313431b41e5094cfcd021284bbece.tar.gz
llvm-2a4c484739b313431b41e5094cfcd021284bbece.tar.bz2
[Support] Avoid repeated hash lookups (NFC) (#123503)
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 5febdf9..e489282 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;