[Bf-blender-cvs] [b58ba3aa472] soc-2021-adaptive-cloth: bli: generational_arena: use better constructor and better if-else
ishbosamiya
noreply at git.blender.org
Sat Jun 19 20:24:17 CEST 2021
Commit: b58ba3aa4726a1cecbbbbde2fa476e92bf3194b6
Author: ishbosamiya
Date: Sat Jun 19 23:53:38 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBb58ba3aa4726a1cecbbbbde2fa476e92bf3194b6
bli: generational_arena: use better constructor and better if-else
===================================================================
M source/blender/blenlib/BLI_generational_arena.hh
===================================================================
diff --git a/source/blender/blenlib/BLI_generational_arena.hh b/source/blender/blenlib/BLI_generational_arena.hh
index 57c5d6a7374..3e9a12450a2 100644
--- a/source/blender/blenlib/BLI_generational_arena.hh
+++ b/source/blender/blenlib/BLI_generational_arena.hh
@@ -153,10 +153,8 @@ class Arena {
T value;
usize generation;
- EntryExist(T value, usize generation)
+ EntryExist(T value, usize generation) : value(value), generation(generation)
{
- this->value = value;
- this->generation = generation;
}
};
@@ -219,19 +217,19 @@ class Arena {
{
if (this->next_free_head) {
auto loc = *this->next_free_head;
+
if (auto entry = std::get_if<EntryNoExist>(&this->data[loc])) {
this->next_free_head = entry->next_free;
this->data[loc] = EntryExist(value, this->generation);
+ this->length += 1;
+ return Index(loc, this->generation);
}
- else {
- /* The linked list created to
- * know where to insert next is
- * corrupted.
- * `this->next_free_head` is corrupted */
- BLI_assert_unreachable();
- }
- this->length += 1;
- return Index(loc, this->generation);
+
+ /* The linked list created to
+ * know where to insert next is
+ * corrupted.
+ * `this->next_free_head` is corrupted */
+ BLI_assert_unreachable();
}
return std::nullopt;
}
More information about the Bf-blender-cvs
mailing list