From 32c8869973ea85647a0d5442557fc3bfdae6424f Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 16 Dec 2022 18:13:40 +0100 Subject: [PATCH] Option: Simplify release_value This avoids copying + we don't need to destroy the item if we move it, since it either gets emptied by moving it or doesn't have anything to destroy. --- luna/include/luna/Option.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/luna/include/luna/Option.h b/luna/include/luna/Option.h index a80cf433..9ef4a58d 100644 --- a/luna/include/luna/Option.h +++ b/luna/include/luna/Option.h @@ -50,10 +50,8 @@ template class Option T release_value() { expect(has_value(), "Option::release_value called on an empty Option"); - T item = m_storage.fetch_reference(); m_has_value = false; - m_storage.destroy(); - return move(item); + return move(m_storage.fetch_reference()); } T value_or(const T& other) const