[llvm] 2a4c484 - [Support] Avoid repeated hash lookups (NFC) (#123503)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 19 10:58:53 PST 2025


Author: Kazu Hirata
Date: 2025-01-19T10:58:49-08:00
New Revision: 2a4c484739b313431b41e5094cfcd021284bbece

URL: https://github.com/llvm/llvm-project/commit/2a4c484739b313431b41e5094cfcd021284bbece
DIFF: https://github.com/llvm/llvm-project/commit/2a4c484739b313431b41e5094cfcd021284bbece.diff

LOG: [Support] Avoid repeated hash lookups (NFC) (#123503)

Added: 
    

Modified: 
    llvm/lib/Support/VirtualFileSystem.cpp

Removed: 
    


################################################################################
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