Optimize flat_list::clear for the case of trivially-destructible types
This commit is contained in:
parent
e3c42627c4
commit
ccef8f91ea
1 changed files with 8 additions and 0 deletions
|
|
@ -162,6 +162,14 @@ namespace psemek::util
|
||||||
template <typename T, typename Handle>
|
template <typename T, typename Handle>
|
||||||
void flat_list<T, Handle>::clear()
|
void flat_list<T, Handle>::clear()
|
||||||
{
|
{
|
||||||
|
if constexpr (std::is_trivially_destructible_v<T>)
|
||||||
|
{
|
||||||
|
nodes_.reset();
|
||||||
|
capacity_ = 0;
|
||||||
|
first_ = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (size_ == 0)
|
if (size_ == 0)
|
||||||
{
|
{
|
||||||
nodes_.reset();
|
nodes_.reset();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue