[clang] [Format] Avoid repeated hash lookups (NFC) (PR #108794)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 15 23:43:03 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/108794.diff
1 Files Affected:
- (modified) clang/lib/Format/MacroExpander.cpp (+3-2)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/108794
More information about the cfe-commits
mailing list