| commit | 9de232f1455e2f0bb88f7186f323bd9a2fe0fde1 | [log] [tgz] |
|---|---|---|
| author | dan sinclair <dsinclair@chromium.org> | Thu Jun 26 16:59:39 2025 -0700 |
| committer | Dawn LUCI CQ <dawn-scoped@luci-project-accounts.iam.gserviceaccount.com> | Thu Jun 26 16:59:39 2025 -0700 |
| tree | d48aa7efce2b3b85abaf789dbb3b80efe0d37d1e | |
| parent | 6ae0067f00d4dbafb33d689b559bbea26f15f3ee [diff] |
Reset count when clearing the hash map/set. When calling `Clear` of the `Hashmap` or `Hashset` we'd remove all entries but not reset `count_`. So, if you then called `IsEmpty` the map would return false. Bug: 428007402 Change-Id: I868f0936033b049328dfcb810fe9379d5613ce02 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/249315 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: dan sinclair <dsinclair@chromium.org> Commit-Queue: James Price <jrprice@google.com> Auto-Submit: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/utils/containers/hashmap_base.h b/src/tint/utils/containers/hashmap_base.h index 979fda2..0ef5abd 100644 --- a/src/tint/utils/containers/hashmap_base.h +++ b/src/tint/utils/containers/hashmap_base.h
@@ -288,6 +288,7 @@ } slots_[slot_idx].nodes = nullptr; } + count_ = 0; } /// Ensures that the map can hold @p n entries without heap reallocation or rehashing.
diff --git a/src/tint/utils/containers/hashmap_test.cc b/src/tint/utils/containers/hashmap_test.cc index f3b91bd..4526d5d 100644 --- a/src/tint/utils/containers/hashmap_test.cc +++ b/src/tint/utils/containers/hashmap_test.cc
@@ -462,6 +462,8 @@ case 6: { // Clear reference.clear(); map.Clear(); + ASSERT_TRUE(reference.empty()); + ASSERT_TRUE(map.IsEmpty()); break; } }
diff --git a/src/tint/utils/containers/hashset_test.cc b/src/tint/utils/containers/hashset_test.cc index e9ae39e..7cde440 100644 --- a/src/tint/utils/containers/hashset_test.cc +++ b/src/tint/utils/containers/hashset_test.cc
@@ -141,6 +141,8 @@ case 4: { // Clear reference.clear(); set.Clear(); + ASSERT_TRUE(reference.empty()); + ASSERT_TRUE(set.IsEmpty()); break; } }