diff --git a/libs/util/include/psemek/util/flat_list.hpp b/libs/util/include/psemek/util/flat_list.hpp index 3c8e9dec..6dd9587d 100644 --- a/libs/util/include/psemek/util/flat_list.hpp +++ b/libs/util/include/psemek/util/flat_list.hpp @@ -169,29 +169,31 @@ namespace psemek::util first_ = null; return; } - - if (size_ == 0) + else { + if (size_ == 0) + { + nodes_.reset(); + capacity_ = 0; + first_ = null; + return; + } + + for (Handle h = first_; h != null;) + { + auto next = nodes_[h].next; + new (&nodes_[h].value) T; + h = next; + } + + for (std::size_t i = 0; i < capacity_; ++i) + nodes_[i].value.~T(); + nodes_.reset(); capacity_ = 0; + size_ = 0; first_ = null; - return; } - - for (Handle h = first_; h != null;) - { - auto next = nodes_[h].next; - new (&nodes_[h].value) T; - h = next; - } - - for (std::size_t i = 0; i < capacity_; ++i) - nodes_[i].value.~T(); - - nodes_.reset(); - capacity_ = 0; - size_ = 0; - first_ = null; } template