Optimize flat_list::clear for the case of trivially-destructible types

This commit is contained in:
Nikita Lisitsa 2020-11-26 14:43:30 +03:00
parent e3c42627c4
commit ccef8f91ea

View file

@ -162,6 +162,14 @@ namespace psemek::util
template <typename T, typename Handle>
void flat_list<T, Handle>::clear()
{
if constexpr (std::is_trivially_destructible_v<T>)
{
nodes_.reset();
capacity_ = 0;
first_ = null;
return;
}
if (size_ == 0)
{
nodes_.reset();