Merge branch 'blender-v3.1-release'

This commit is contained in:
Jacques Lucke 2022-02-02 13:12:12 +01:00
commit e54fba5591
2 changed files with 14 additions and 0 deletions

View File

@ -570,6 +570,10 @@ class VectorSet {
if (this->size() == 0) {
try {
slots_.reinitialize(total_slots);
if (keys_ != nullptr) {
this->deallocate_keys_array(keys_);
keys_ = nullptr;
}
keys_ = this->allocate_keys_array(usable_slots);
}
catch (...) {

View File

@ -271,4 +271,14 @@ TEST(vector_set, LookupKey)
EXPECT_EQ(set.lookup_key_ptr("a"), set.lookup_key_ptr_as("a"));
}
TEST(vector_set, GrowWhenEmpty)
{
/* Tests that the internal keys array is freed correctly when growing an empty set. */
VectorSet<int> set;
set.add(4);
set.remove(4);
EXPECT_TRUE(set.is_empty());
set.reserve(100);
}
} // namespace blender::tests