mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:27:42 +00:00
LibGUI: Optimize GUI::Variant move constructor
This commit is contained in:
parent
d0812e9019
commit
4062add8ed
2 changed files with 11 additions and 3 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <AK/FlyString.h>
|
#include <AK/FlyString.h>
|
||||||
#include <AK/JsonValue.h>
|
#include <AK/JsonValue.h>
|
||||||
|
#include <AK/RefPtr.h>
|
||||||
#include <LibGUI/Variant.h>
|
#include <LibGUI/Variant.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -255,10 +256,8 @@ Variant& Variant::operator=(Variant&& other)
|
||||||
{
|
{
|
||||||
if (&other == this)
|
if (&other == this)
|
||||||
return *this;
|
return *this;
|
||||||
// FIXME: Move, not copy!
|
|
||||||
clear();
|
clear();
|
||||||
copy_from(other);
|
move_from(AK::move(other));
|
||||||
other.clear();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,6 +266,14 @@ Variant::Variant(const Variant& other)
|
||||||
copy_from(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)
|
void Variant::copy_from(const Variant& other)
|
||||||
{
|
{
|
||||||
ASSERT(!is_valid());
|
ASSERT(!is_valid());
|
||||||
|
|
|
@ -250,6 +250,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void copy_from(const Variant&);
|
void copy_from(const Variant&);
|
||||||
|
void move_from(Variant&&);
|
||||||
|
|
||||||
struct RawPoint {
|
struct RawPoint {
|
||||||
int x;
|
int x;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue