Commit 513212c5 authored by Max Kellermann's avatar Max Kellermann

input/async: use std::exchange()

parent 99a447df
...@@ -50,8 +50,7 @@ AsyncInputStream::~AsyncInputStream() ...@@ -50,8 +50,7 @@ AsyncInputStream::~AsyncInputStream()
void void
AsyncInputStream::SetTag(Tag *_tag) noexcept AsyncInputStream::SetTag(Tag *_tag) noexcept
{ {
delete tag; delete std::exchange(tag, _tag);
tag = _tag;
} }
void void
...@@ -77,11 +76,9 @@ AsyncInputStream::Resume() ...@@ -77,11 +76,9 @@ AsyncInputStream::Resume()
void void
AsyncInputStream::Check() AsyncInputStream::Check()
{ {
if (postponed_exception) { if (postponed_exception)
auto e = std::move(postponed_exception); std::rethrow_exception(std::exchange(postponed_exception,
postponed_exception = std::exception_ptr(); std::exception_ptr()));
std::rethrow_exception(e);
}
} }
bool bool
...@@ -154,9 +151,7 @@ AsyncInputStream::SeekDone() noexcept ...@@ -154,9 +151,7 @@ AsyncInputStream::SeekDone() noexcept
Tag * Tag *
AsyncInputStream::ReadTag() AsyncInputStream::ReadTag()
{ {
Tag *result = tag; return std::exchange(tag, nullptr);
tag = nullptr;
return result;
} }
bool bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment