LibThreading: Pass ownership of a BackgroundAction result to its caller

There is no need to create a copy of potentially expensive structures.
This commit is contained in:
Timothy Flynn 2025-02-09 13:03:56 -05:00 committed by Sam Atkins
parent f20aa82c27
commit 5f9ed343b3
Notes: github-actions[bot] 2025-02-10 16:06:43 +00:00

View file

@ -65,7 +65,7 @@ private:
promise->on_resolution = [](NonnullRefPtr<Core::EventReceiver>& object) -> ErrorOr<void> {
auto self = static_ptr_cast<BackgroundAction<Result>>(object);
VERIFY(self->m_result.has_value());
if (auto maybe_error = self->m_on_complete(self->m_result.value()); maybe_error.is_error())
if (auto maybe_error = self->m_on_complete(self->m_result.release_value()); maybe_error.is_error())
self->m_on_error(maybe_error.release_error());
return {};