mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Merge pull request #93276 from mashumafi/avoid-vec-copy
Avoid unnecessary copy-on-write Vector/Array
This commit is contained in:
@@ -315,8 +315,8 @@ public:
|
||||
|
||||
template <typename T>
|
||||
void Vector<T>::reverse() {
|
||||
T *p = ptrw();
|
||||
for (Size i = 0; i < size() / 2; i++) {
|
||||
T *p = ptrw();
|
||||
SWAP(p[i], p[size() - i - 1]);
|
||||
}
|
||||
}
|
||||
@@ -329,8 +329,9 @@ void Vector<T>::append_array(Vector<T> p_other) {
|
||||
}
|
||||
const Size bs = size();
|
||||
resize(bs + ds);
|
||||
T *p = ptrw();
|
||||
for (Size i = 0; i < ds; ++i) {
|
||||
ptrw()[bs + i] = p_other[i];
|
||||
p[bs + i] = p_other[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user