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:
João Abecasis 2012-01-06 14:38:57 +01:00 committed by Qt by Nokia
parent 25b8b2437c
commit 5a92bc9760

View File

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