[clang] 280d2a3 - [AST] Avoid repeated hash lookups (NFC) (#126461)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 07:49:00 PST 2025
Author: Kazu Hirata
Date: 2025-02-10T07:48:57-08:00
New Revision: 280d2a3035ad362cb9dab9f59aa9bdbb88723e9e
URL: https://github.com/llvm/llvm-project/commit/280d2a3035ad362cb9dab9f59aa9bdbb88723e9e
DIFF: https://github.com/llvm/llvm-project/commit/280d2a3035ad362cb9dab9f59aa9bdbb88723e9e.diff
LOG: [AST] Avoid repeated hash lookups (NFC) (#126461)
Added:
Modified:
clang/lib/AST/RawCommentList.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index fddedd3a31856a3..9658c6ab3d39dd6 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.
More information about the cfe-commits
mailing list