From d6ce0bad67c6961dc87469db7ac81144a52e875f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 5 Jun 2023 11:03:51 +0200 Subject: [PATCH] QFusionStyle: de-pessimize arrow painting Instead of holding three QPointF's in a QPolygonF, which will allocate them on the heap, use QVarLengthArray<>, which will allocate them on the stack instead. Pick-to: 6.6 6.5 Task-numbber: QTBUG-112200 Change-Id: If078e5a9a5cb82fd03b511e28cceb88bd42996f8 Reviewed-by: Qt CI Bot Reviewed-by: Volker Hilsheimer --- src/widgets/styles/qfusionstyle.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 95d0de89231..64a0b3c7217 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -241,8 +241,7 @@ static void qt_fusion_draw_arrow(Qt::ArrowType type, QPainter *painter, const QS arrowRect.moveTo((rect.width() - arrowRect.width()) / 2.0, (rect.height() - arrowRect.height()) / 2.0); - QPolygonF triangle; - triangle.reserve(3); + QVarLengthArray triangle; switch (type) { case Qt::DownArrow: triangle << arrowRect.topLeft() << arrowRect.topRight() << QPointF(arrowRect.center().x(), arrowRect.bottom()); @@ -261,7 +260,7 @@ static void qt_fusion_draw_arrow(Qt::ArrowType type, QPainter *painter, const QS cachePainter.setPen(Qt::NoPen); cachePainter.setBrush(color); cachePainter.setRenderHint(QPainter::Antialiasing); - cachePainter.drawPolygon(triangle); + cachePainter.drawPolygon(triangle.data(), int(triangle.size())); QPixmapCache::insert(cacheKey, cachePixmap); }