Am 04.03.2018 um 10:03 schrieb Christian Ehrlicher:
Am 03.03.2018 um 23:22 schrieb Martins, Sérgio:
On 2018-03-03 20:38, Christian Ehrlicher wrote:
But it looks like reserve()
allocates *exactly* the amount of elements given.
Actually that qpainterpath code is off-by-one, it should be:
d_func()->elements.reserve(d_func()->elements.size() + polygon.size()
- 1);
which also fixes the performance problem (by luck, in that specific
benchmark). Please test.
You're correct - this fixes the problem. Looks like the growth
strategy is only applied when the current capacity == current size and
not when the current capacity is slightly higher... good to know (and
should maybe be documented?)
The off-by-one idea was wrong. moveTo() will add another point to
elements - therefore reserve(d_func()->elements.size() + polygon.size())
is correct.
Maybe the best idea here would be to simply remove the reserve() calls
and let QVector do what it is made for... :)
Christian
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development