Merge pull request #93276 from mashumafi/avoid-vec-copy

Avoid unnecessary copy-on-write Vector/Array
This commit is contained in:
Rémi Verschelde
2025-05-13 01:04:16 +02:00
2 changed files with 4 additions and 3 deletions

View File

@@ -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];
}
}