https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/108794
None >From e5a86bbb661aba2d68acff0b28944f523adb490a Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Sun, 15 Sep 2024 01:35:59 -0700 Subject: [PATCH] [Format] Avoid repeated hash lookups (NFC) --- clang/lib/Format/MacroExpander.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/MacroExpander.cpp b/clang/lib/Format/MacroExpander.cpp index 5768ff37fefcda..fd2a16894d643d 100644 --- a/clang/lib/Format/MacroExpander.cpp +++ b/clang/lib/Format/MacroExpander.cpp @@ -191,9 +191,10 @@ MacroExpander::expand(FormatToken *ID, auto expandArgument = [&](FormatToken *Tok) -> bool { // If the current token references a parameter, expand the corresponding // argument. - if (Tok->isNot(tok::identifier) || ExpandedArgs.contains(Tok->TokenText)) + if (Tok->isNot(tok::identifier)) + return false; + if (!ExpandedArgs.insert(Tok->TokenText).second) return false; - ExpandedArgs.insert(Tok->TokenText); auto I = Def.ArgMap.find(Tok->TokenText); if (I == Def.ArgMap.end()) return false; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits