Don't allocate when inserting overlapping data
(This is only for a test case, but still...) Change-Id: Ied205860e5469000249e15a5478c10db53f1fdaa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
This commit is contained in:
parent
25b8b2437c
commit
5a92bc9760
@ -237,11 +237,15 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// Temporarily copy overlapping data, if needed
|
||||
if ((first >= where && first < end)
|
||||
|| (last > where && last <= end)) {
|
||||
SimpleVector tmp(first, last);
|
||||
d->insert(where, tmp.constBegin(), tmp.constEnd());
|
||||
// Copy overlapping data first and only then shuffle it into place
|
||||
T *start = d->begin() + position;
|
||||
T *middle = d->end();
|
||||
|
||||
d->copyAppend(first, last);
|
||||
std::rotate(start, middle, d->end());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user