Skip to content

Commit 3c47182

Browse files
committed
optimize holder move
1 parent 6413a1e commit 3c47182

File tree

1 file changed

+5
-4
lines changed
  • sources/include/cage-core

1 file changed

+5
-4
lines changed

sources/include/cage-core/core.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,10 +781,11 @@ namespace cage
781781

782782
HolderBase &operator=(HolderBase &&other)
783783
{
784-
HolderBase tmp(other.share());
785-
clear();
786-
std::swap(data_, tmp.data_);
787-
std::swap(control_, tmp.control_);
784+
if (&other == this)
785+
return *this;
786+
std::swap(data_, other.data_);
787+
std::swap(control_, other.control_);
788+
other.clear();
788789
return *this;
789790
}
790791

0 commit comments

Comments
 (0)