mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Merge pull request #100560 from Ivorforce/localvector-move-semantics
Add `LocalVector` move semantics (constructor and operator=).
This commit is contained in:
@@ -326,6 +326,16 @@ public:
|
|||||||
data[i] = p_from.data[i];
|
data[i] = p_from.data[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_FORCE_INLINE_ LocalVector(LocalVector &&p_from) {
|
||||||
|
data = p_from.data;
|
||||||
|
count = p_from.count;
|
||||||
|
capacity = p_from.capacity;
|
||||||
|
|
||||||
|
p_from.data = nullptr;
|
||||||
|
p_from.count = 0;
|
||||||
|
p_from.capacity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
inline void operator=(const LocalVector &p_from) {
|
inline void operator=(const LocalVector &p_from) {
|
||||||
resize(p_from.size());
|
resize(p_from.size());
|
||||||
for (U i = 0; i < p_from.count; i++) {
|
for (U i = 0; i < p_from.count; i++) {
|
||||||
@@ -338,6 +348,26 @@ public:
|
|||||||
data[i] = p_from[i];
|
data[i] = p_from[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inline void operator=(LocalVector &&p_from) {
|
||||||
|
if (unlikely(this == &p_from)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reset();
|
||||||
|
|
||||||
|
data = p_from.data;
|
||||||
|
count = p_from.count;
|
||||||
|
capacity = p_from.capacity;
|
||||||
|
|
||||||
|
p_from.data = nullptr;
|
||||||
|
p_from.count = 0;
|
||||||
|
p_from.capacity = 0;
|
||||||
|
}
|
||||||
|
inline void operator=(Vector<T> &&p_from) {
|
||||||
|
resize(p_from.size());
|
||||||
|
for (U i = 0; i < count; i++) {
|
||||||
|
data[i] = std::move(p_from[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_FORCE_INLINE_ ~LocalVector() {
|
_FORCE_INLINE_ ~LocalVector() {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user