[clang] [AST] Avoid repeated hash lookups (NFC) (PR #126461)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 9 21:22:02 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/126461.diff
1 Files Affected:
- (modified) clang/lib/AST/RawCommentList.cpp (+4-4)
``````````diff
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index fddedd3a31856a..9658c6ab3d39dd 100644
--- a/clang/lib/AST/RawCommentList.cpp
+++ b/clang/lib/AST/RawCommentList.cpp
@@ -287,13 +287,13 @@ void RawCommentList::addComment(const RawComment &RC,
// If this is the first Doxygen comment, save it (because there isn't
// anything to merge it with).
- if (OrderedComments[CommentFile].empty()) {
- OrderedComments[CommentFile][CommentOffset] =
- new (Allocator) RawComment(RC);
+ auto &OC = OrderedComments[CommentFile];
+ if (OC.empty()) {
+ OC[CommentOffset] = new (Allocator) RawComment(RC);
return;
}
- const RawComment &C1 = *OrderedComments[CommentFile].rbegin()->second;
+ const RawComment &C1 = *OC.rbegin()->second;
const RawComment &C2 = RC;
// Merge comments only if there is only whitespace between them.
``````````
</details>
https://github.com/llvm/llvm-project/pull/126461
More information about the cfe-commits
mailing list