[clang] [AST] Avoid repeated hash lookups (NFC) (PR #127299)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 14 21:32:51 PST 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/127299

None

>From 3271e58d37eee93866d74d5bfbf090b2c385b883 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 14 Feb 2025 09:32:34 -0800
Subject: [PATCH] [AST] Avoid repeated hash lookups (NFC)

---
 clang/lib/AST/VTableBuilder.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 19d76df99dbe3..18893b996b5d6 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -2115,8 +2115,8 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
 
     // Dump the next address point.
     uint64_t NextIndex = Index + 1;
-    if (AddressPointsByIndex.count(NextIndex)) {
-      if (AddressPointsByIndex.count(NextIndex) == 1) {
+    if (unsigned Count = AddressPointsByIndex.count(NextIndex)) {
+      if (Count == 1) {
         const BaseSubobject &Base =
           AddressPointsByIndex.find(NextIndex)->second;
 



More information about the cfe-commits mailing list