@@ -224,7 +224,7 @@ ThreadSafeTrieRawHashMapBase::find(ArrayRef<uint8_t> Hash) const {
224
224
TrieSubtrie *S = &Impl->Root ;
225
225
IndexGenerator IndexGen{NumRootBits, NumSubtrieBits, Hash};
226
226
size_t Index = IndexGen.next ();
227
- while (true ) {
227
+ while (Index != IndexGen. end () ) {
228
228
// Try to set the content.
229
229
TrieNode *Existing = S->get (Index);
230
230
if (!Existing)
@@ -239,6 +239,7 @@ ThreadSafeTrieRawHashMapBase::find(ArrayRef<uint8_t> Hash) const {
239
239
Index = IndexGen.next ();
240
240
S = cast<TrieSubtrie>(Existing);
241
241
}
242
+ llvm_unreachable (" failed to locate the node after consuming all hash bytes" );
242
243
}
243
244
244
245
ThreadSafeTrieRawHashMapBase::PointerBase ThreadSafeTrieRawHashMapBase::insert (
@@ -258,7 +259,7 @@ ThreadSafeTrieRawHashMapBase::PointerBase ThreadSafeTrieRawHashMapBase::insert(
258
259
Index = IndexGen.next ();
259
260
}
260
261
261
- while (true ) {
262
+ while (Index != IndexGen. end () ) {
262
263
// Load the node from the slot, allocating and calling the constructor if
263
264
// the slot is empty.
264
265
bool Generated = false ;
@@ -292,8 +293,8 @@ ThreadSafeTrieRawHashMapBase::PointerBase ThreadSafeTrieRawHashMapBase::insert(
292
293
return PointerBase (ExistingContent.getValuePointer ());
293
294
294
295
// Sink the existing content as long as the indexes match.
295
- while ( true ) {
296
- size_t NextIndex = IndexGen.next ();
296
+ size_t NextIndex = IndexGen. next ();
297
+ while ( NextIndex ! = IndexGen.end ()) {
297
298
size_t NewIndexForExistingContent =
298
299
IndexGen.getCollidingBits (ExistingContent.getHash ());
299
300
S = S->sink (Index, ExistingContent, IndexGen.getNumBits (),
@@ -306,8 +307,11 @@ ThreadSafeTrieRawHashMapBase::PointerBase ThreadSafeTrieRawHashMapBase::insert(
306
307
// Found the difference.
307
308
if (NextIndex != NewIndexForExistingContent)
308
309
break ;
310
+
311
+ NextIndex = IndexGen.next ();
309
312
}
310
313
}
314
+ llvm_unreachable (" failed to insert the node after consuming all hash bytes" );
311
315
}
312
316
313
317
ThreadSafeTrieRawHashMapBase::ThreadSafeTrieRawHashMapBase (
0 commit comments