diff --git a/src/util/IntrusiveList.hxx b/src/util/IntrusiveList.hxx index f8b5116e5..6e10f9797 100644 --- a/src/util/IntrusiveList.hxx +++ b/src/util/IntrusiveList.hxx @@ -264,9 +264,7 @@ public: void clear_and_dispose(Disposer auto disposer) noexcept { while (!empty()) { - auto *item = &front(); - pop_front(); - disposer(item); + disposer(&pop_front()); } } @@ -302,15 +300,15 @@ public: return *Cast(head.next); } - void pop_front() noexcept { - ToHook(front()).unlink(); - --counter; - } - - void pop_front_and_dispose(Disposer auto disposer) noexcept { + reference pop_front() noexcept { auto &i = front(); ToHook(i).unlink(); --counter; + return i; + } + + void pop_front_and_dispose(Disposer auto disposer) noexcept { + auto &i = pop_front(); disposer(&i); } @@ -319,7 +317,8 @@ public: } void pop_back() noexcept { - ToHook(back()).unlink(); + auto &i = back(); + ToHook(i).unlink(); --counter; }