diff options
author | Jacques Lucke <jacques@blender.org> | 2021-03-25 17:31:09 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-25 18:01:41 +0300 |
commit | 9b426269189ce00add24e48c951c45aca01f2076 (patch) | |
tree | 5c62976de44a0703fe39b251d91ea65ccfae098f /source/blender | |
parent | 56df673be271c10200d758e0b0e891750103f8d6 (diff) |
BLI: fix Set.lookup_key_or_add
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_set.hh | 2 | ||||
-rw-r--r-- | source/blender/blenlib/tests/BLI_set_test.cc | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh index fef657b2d8f..a8ccf957f6c 100644 --- a/source/blender/blenlib/BLI_set.hh +++ b/source/blender/blenlib/BLI_set.hh @@ -788,6 +788,8 @@ class Set { template<typename ForwardKey> const Key &lookup_key_or_add__impl(ForwardKey &&key, const uint64_t hash) { + this->ensure_can_add(); + SET_SLOT_PROBING_BEGIN (hash, slot) { if (slot.contains(key, is_equal_, hash)) { return *slot.key(); diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc index 56f1d57e4ae..3a4733a218f 100644 --- a/source/blender/blenlib/tests/BLI_set_test.cc +++ b/source/blender/blenlib/tests/BLI_set_test.cc @@ -456,8 +456,8 @@ TEST(set, LookupKeyPtr) TEST(set, LookupKeyOrAdd) { Set<MyKeyType> set; - set.add({1, 10}); - set.add({2, 20}); + set.lookup_key_or_add({1, 10}); + set.lookup_key_or_add({2, 20}); EXPECT_EQ(set.size(), 2); EXPECT_EQ(set.lookup_key_or_add({2, 40}).attached_data, 20); EXPECT_EQ(set.size(), 2); |