Commit c4fadd41 authored by Ronan's avatar Ronan

fix(Variant): use `swap` when possible

parent a30050c8
......@@ -108,8 +108,7 @@ Variant::Variant (const Variant &src) {
Variant::Variant (Variant &&src) {
// Don't call placement new.
L_ASSERT(!mPrivate);
mPrivate = src.mPrivate;
src.mPrivate = nullptr;
::swap(mPrivate, src.mPrivate);
}
Variant::Variant (int value) : Variant(Int) {
......@@ -220,13 +219,7 @@ Variant &Variant::operator= (const Variant &variant) {
}
Variant &Variant::operator= (Variant &&variant) {
// Unset old d.
delete mPrivate;
// Set new d.
mPrivate = variant.mPrivate;
variant.mPrivate = nullptr;
::swap(mPrivate, variant.mPrivate);
return *this;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment