Re: [Development] QVector reserve counterproductive?

2018-03-04 Thread Martins , Sérgio
On 2018-03-04 13:20, Christian Ehrlicher wrote: 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

Re: [Development] QVector reserve counterproductive?

2018-03-04 Thread Christian Ehrlicher
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:

Re: [Development] QVector reserve counterproductive?

2018-03-04 Thread 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() +

Re: [Development] QVector reserve counterproductive?

2018-03-03 Thread Martins , Sérgio
On 2018-03-03 20:38, Christian Ehrlicher wrote: Hi, while digging through the bugreports I found https://bugreports.qt.io/browse/QTBUG-66677 which seems to show a downside of QVector::reserve(). Yes, reserve() shouldn't be called repeatedly inside loops. Instead use it only once, outside

[Development] QVector reserve counterproductive?

2018-03-03 Thread Christian Ehrlicher
Hi, while digging through the bugreports I found https://bugreports.qt.io/browse/QTBUG-66677 which seems to show a downside of QVector::reserve(). QPainterPath::addPolygon() is calling reserve() to make sure to have enough space for the new positions. This is exactly what I would have done