QtGui: use reserve to optimize memory allocation.
Change-Id: I34a571b67840557de19ab496cadebd698c7f4f6a Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
8dc024adc6
commit
97965a0908
@ -473,6 +473,7 @@ QVector<T> fromNativePixels(const QVector<T> &pixelValues, const QWindow *window
|
||||
return pixelValues;
|
||||
|
||||
QVector<T> pointValues;
|
||||
pointValues.reserve(pixelValues.size());
|
||||
for (const T &pixelValue : pixelValues)
|
||||
pointValues.append(pixelValue / QHighDpiScaling::factor(window));
|
||||
return pointValues;
|
||||
@ -486,6 +487,7 @@ QVector<T> toNativePixels(const QVector<T> &pointValues, const QWindow *window)
|
||||
return pointValues;
|
||||
|
||||
QVector<T> pixelValues;
|
||||
pixelValues.reserve(pointValues.size());
|
||||
for (const T &pointValue : pointValues)
|
||||
pixelValues.append(pointValue * QHighDpiScaling::factor(window));
|
||||
return pixelValues;
|
||||
|
@ -928,7 +928,7 @@ static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoi
|
||||
static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList)
|
||||
{
|
||||
QList<struct QWindowSystemInterface::TouchPoint> newList;
|
||||
|
||||
newList.reserve(pointList.size());
|
||||
for (const QTouchEvent::TouchPoint &p : pointList)
|
||||
newList.append(touchPoint(p));
|
||||
|
||||
|
@ -624,6 +624,7 @@ static QTtfTable generateName(const QVector<QTtfNameRecord> &name);
|
||||
static QTtfTable generateName(const qttf_name_table &name)
|
||||
{
|
||||
QVector<QTtfNameRecord> list;
|
||||
list.reserve(5);
|
||||
QTtfNameRecord rec;
|
||||
rec.nameId = 0;
|
||||
rec.value = name.copyright;
|
||||
@ -1061,6 +1062,7 @@ static QVector<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QV
|
||||
Q_ASSERT(hmtx.data.size() == hs.offset());
|
||||
|
||||
QVector<QTtfTable> list;
|
||||
list.reserve(3);
|
||||
list.append(glyf);
|
||||
list.append(loca);
|
||||
list.append(hmtx);
|
||||
|
Loading…
Reference in New Issue
Block a user