[llvm] [MCParser] Avoid repeated hash lookups (NFC) (PR #110204)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 19:55:43 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/110204

None

>From d1a472d68e45b49bf2ee5f2c57bd1b1b07052ac8 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 26 Sep 2024 08:14:23 -0700
Subject: [PATCH] [MCParser] Avoid repeated hash lookups (NFC)

---
 llvm/lib/MC/MCParser/MasmParser.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index c5ff1e7acbfd2a..d88fd09a1aa07c 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -479,9 +479,7 @@ class MasmParser : public MCAsmParser {
   void addDirectiveHandler(StringRef Directive,
                            ExtensionDirectiveHandler Handler) override {
     ExtensionDirectiveMap[Directive] = Handler;
-    if (!DirectiveKindMap.contains(Directive)) {
-      DirectiveKindMap[Directive] = DK_HANDLER_DIRECTIVE;
-    }
+    DirectiveKindMap.try_emplace(Directive, DK_HANDLER_DIRECTIVE);
   }
 
   void addAliasForDirective(StringRef Directive, StringRef Alias) override {



More information about the llvm-commits mailing list