diff --git a/src/tint/utils/hashmap_base.h b/src/tint/utils/hashmap_base.h index 0460373cff..ca0712ae72 100644 --- a/src/tint/utils/hashmap_base.h +++ b/src/tint/utils/hashmap_base.h @@ -453,12 +453,18 @@ class HashmapBase { /// * must return Action::kStop within one whole cycle of the slots. template void Scan(size_t start, F&& f) const { - size_t index = start; - for (size_t distance = 0; distance < slots_.Length(); distance++) { + size_t distance = 0; + for (size_t index = start; index < slots_.Length(); index++) { if (f(distance, index) == Action::kStop) { return; } - index = Wrap(index + 1); + distance++; + } + for (size_t index = 0; index < start; index++) { + if (f(distance, index) == Action::kStop) { + return; + } + distance++; } tint::diag::List diags; TINT_ICE(Utils, diags) << "HashmapBase::Scan() looped entire map without finding a slot";