[clang] [AST] Avoid repeated set lookups (NFC) (PR #112155)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 13 21:01:40 PDT 2024


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

None

>From d484b61db4ac1645358faa30962d406413f0714b Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 13 Oct 2024 07:42:03 -0700
Subject: [PATCH] [AST] Avoid repeated set lookups (NFC)

---
 clang/lib/AST/InheritViz.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/AST/InheritViz.cpp b/clang/lib/AST/InheritViz.cpp
index 2ed0ce1c79c5bd..1dafed837a3560 100644
--- a/clang/lib/AST/InheritViz.cpp
+++ b/clang/lib/AST/InheritViz.cpp
@@ -63,12 +63,11 @@ void InheritanceHierarchyWriter::WriteNode(QualType Type, bool FromVirtual) {
   QualType CanonType = Context.getCanonicalType(Type);
 
   if (FromVirtual) {
-    if (KnownVirtualBases.find(CanonType) != KnownVirtualBases.end())
+    if (!KnownVirtualBases.insert(CanonType).second)
       return;
 
     // We haven't seen this virtual base before, so display it and
     // its bases.
-    KnownVirtualBases.insert(CanonType);
   }
 
   // Declare the node itself.



More information about the cfe-commits mailing list