From 5f9ed343b3ab7b7555e822b50d78131f3563848b Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 9 Feb 2025 13:03:56 -0500 Subject: [PATCH] LibThreading: Pass ownership of a BackgroundAction result to its caller There is no need to create a copy of potentially expensive structures. --- Libraries/LibThreading/BackgroundAction.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibThreading/BackgroundAction.h b/Libraries/LibThreading/BackgroundAction.h index 263b94f6741..2a6c05cd7f3 100644 --- a/Libraries/LibThreading/BackgroundAction.h +++ b/Libraries/LibThreading/BackgroundAction.h @@ -65,7 +65,7 @@ private: promise->on_resolution = [](NonnullRefPtr& object) -> ErrorOr { auto self = static_ptr_cast>(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 {};