mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 07:11:05 -06:00
cmLinkedTree: avoid unnecessary copies during Push of T
This commit is contained in:
@@ -137,7 +137,7 @@ public:
|
|||||||
|
|
||||||
iterator Push(iterator it) { return Push_impl(it, T()); }
|
iterator Push(iterator it) { return Push_impl(it, T()); }
|
||||||
|
|
||||||
iterator Push(iterator it, T t) { return Push_impl(it, t); }
|
iterator Push(iterator it, T t) { return Push_impl(it, std::move(t)); }
|
||||||
|
|
||||||
bool IsLast(iterator it) { return it.Position == this->Data.size(); }
|
bool IsLast(iterator it) { return it.Position == this->Data.size(); }
|
||||||
|
|
||||||
@@ -177,12 +177,12 @@ private:
|
|||||||
|
|
||||||
T* GetPointer(PositionType pos) { return &this->Data[pos]; }
|
T* GetPointer(PositionType pos) { return &this->Data[pos]; }
|
||||||
|
|
||||||
iterator Push_impl(iterator it, T t)
|
iterator Push_impl(iterator it, T&& t)
|
||||||
{
|
{
|
||||||
assert(this->UpPositions.size() == this->Data.size());
|
assert(this->UpPositions.size() == this->Data.size());
|
||||||
assert(it.Position <= this->UpPositions.size());
|
assert(it.Position <= this->UpPositions.size());
|
||||||
this->UpPositions.push_back(it.Position);
|
this->UpPositions.push_back(it.Position);
|
||||||
this->Data.push_back(t);
|
this->Data.push_back(std::move(t));
|
||||||
return iterator(this, this->UpPositions.size());
|
return iterator(this, this->UpPositions.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user