mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 17:15:26 +00:00
LibGUI: Optimize GUI::Variant move constructor
This commit is contained in:
committed by
Andreas Kling
parent
d0812e9019
commit
4062add8ed
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibGUI/Variant.h>
|
||||
|
||||
namespace GUI {
|
||||
@@ -255,10 +256,8 @@ Variant& Variant::operator=(Variant&& other)
|
||||
{
|
||||
if (&other == this)
|
||||
return *this;
|
||||
// FIXME: Move, not copy!
|
||||
clear();
|
||||
copy_from(other);
|
||||
other.clear();
|
||||
move_from(AK::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -267,6 +266,14 @@ Variant::Variant(const Variant& other)
|
||||
copy_from(other);
|
||||
}
|
||||
|
||||
void Variant::move_from(Variant&& other)
|
||||
{
|
||||
m_type = other.m_type;
|
||||
m_value = other.m_value;
|
||||
other.m_type = Type::Invalid;
|
||||
other.m_value.as_string = nullptr;
|
||||
}
|
||||
|
||||
void Variant::copy_from(const Variant& other)
|
||||
{
|
||||
ASSERT(!is_valid());
|
||||
|
||||
Reference in New Issue
Block a user