From 180ad9f05e873551d28e25b4840bf1c02b1ef7ee Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 2 Jun 2015 16:30:17 +0300 Subject: QSGDistanceFieldGlyphNode: Use QVarLengthArray to avoid frequent allocation. This adds a few more text items/frame on my macbook, and more or less halves the amount of transient 608 byte allocations (42mb -> 25mb). Change-Id: Ib1a67c8203f777a2f3b790ff3597d1af34eed2dd Done-with: Gunnar Sletta Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/qsgdistancefieldglyphnode.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp index 7e602fc0bd..4630e45ecf 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp @@ -200,9 +200,11 @@ void QSGDistanceFieldGlyphNode::updateGeometry() const QVector positions = m_glyphs.positions(); qreal fontPixelSize = m_glyphs.rawFont().pixelSize(); - QVector vp; + // The template parameters here are assuming that most strings are short, 64 + // characters or less. + QVarLengthArray vp; vp.reserve(indexes.size() * 4); - QVector ip; + QVarLengthArray ip; ip.reserve(indexes.size() * 6); qreal maxTexMargin = m_glyph_cache->distanceFieldRadius(); -- cgit v1.2.3