[llvm] [ADT] Simplify control flow in ImmutableSet (NFC) (PR #165133)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 25 23:26:35 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/165133
A conventional "if" statement is easier to read than the
do-while(false) pattern used here.
>From 9131323d0d2e3cb9b94ef3e1b1485d46512f6da5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 25 Oct 2025 20:41:47 -0700
Subject: [PATCH] [ADT] Simplify control flow in ImmutableSet (NFC)
A conventional "if" statement is easier to read than the
do-while(false) pattern used here.
---
llvm/include/llvm/ADT/ImmutableSet.h | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/llvm/include/llvm/ADT/ImmutableSet.h b/llvm/include/llvm/ADT/ImmutableSet.h
index 8b2425e4e8fef..1b40dac4d092c 100644
--- a/llvm/include/llvm/ADT/ImmutableSet.h
+++ b/llvm/include/llvm/ADT/ImmutableSet.h
@@ -635,9 +635,7 @@ class ImutAVLFactory {
// if find a collision compare those trees by their contents.
unsigned digest = TNew->computeDigest();
TreeTy *&entry = Cache[maskCacheIndex(digest)];
- do {
- if (!entry)
- break;
+ if (entry) {
for (TreeTy *T = entry ; T != nullptr; T = T->next) {
// Compare the Contents('T') with Contents('TNew')
typename TreeTy::iterator TI = T->begin(), TE = T->end();
@@ -653,7 +651,6 @@ class ImutAVLFactory {
entry->prev = TNew;
TNew->next = entry;
}
- while (false);
entry = TNew;
TNew->IsCanonicalized = true;
More information about the llvm-commits
mailing list