IntrusivePtr: optimize release() using std::exchange()

This commit is contained in:
Max Kellermann 2020-02-25 20:53:29 +01:00
parent 3bc33fe7f6
commit 6f3e9d2c4c

View file

@ -123,10 +123,7 @@ public:
*/ */
pointer release() noexcept pointer release() noexcept
{ {
auto result = ptr_; return std::exchange(ptr_, nullptr);
if ( result )
ptr_ = nullptr;
return result;
} }
IntrusivePtr& operator=(IntrusivePtr other) noexcept IntrusivePtr& operator=(IntrusivePtr other) noexcept