[llvm] b8317df - [FileCheck] Avoid repeated hash lookups (NFC) (#131553)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 17 07:42:00 PDT 2025


Author: Kazu Hirata
Date: 2025-03-17T07:41:51-07:00
New Revision: b8317df8d8f6dc110edfbf86d8269c912cb2a2a9

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

LOG: [FileCheck] Avoid repeated hash lookups (NFC) (#131553)

Added: 
    

Modified: 
    llvm/lib/FileCheck/FileCheck.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index 931a4d3c36f16..072dbefba1f1f 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -1010,8 +1010,10 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix,
         // Handle substitution of string variables that were defined earlier on
         // the same line by emitting a backreference. Expressions do not
         // support substituting a numeric variable defined on the same line.
-        if (!IsNumBlock && VariableDefs.find(SubstStr) != VariableDefs.end()) {
-          unsigned CaptureParenGroup = VariableDefs[SubstStr];
+        decltype(VariableDefs)::iterator It;
+        if (!IsNumBlock &&
+            (It = VariableDefs.find(SubstStr)) != VariableDefs.end()) {
+          unsigned CaptureParenGroup = It->second;
           if (CaptureParenGroup < 1 || CaptureParenGroup > 9) {
             SM.PrintMessage(SMLoc::getFromPointer(SubstStr.data()),
                             SourceMgr::DK_Error,


        


More information about the llvm-commits mailing list