From 876b87b64e0f6a3519ea3e3d58f28ab81a480cae Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 19 Nov 2020 17:23:02 +0000 Subject: [PATCH] Minor performance fixes for PCBNew selections. --- common/gal/stroke_font.cpp | 9 +++++++-- pcbnew/tools/selection_tool.cpp | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index e287de2438..9b6cbec93a 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -332,6 +332,9 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText ) bool in_super_or_subscript = false; VECTOR2D glyphSize = baseGlyphSize; + // Allocate only once (for performance) + std::deque ptListScaled; + yOffset = 0; for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt ) @@ -456,7 +459,8 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText ) for( const std::vector* ptList : *glyph ) { - std::deque ptListScaled; + int ptCount = 0; + ptListScaled.clear(); for( const VECTOR2D& pt : *ptList ) { @@ -473,9 +477,10 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText ) } ptListScaled.push_back( scaledPt ); + ptCount++; } - m_gal->DrawPolyline( ptListScaled ); + m_gal->DrawPolyline( &ptListScaled[0], ptCount ); } xOffset += glyphSize.x * bbox.GetEnd().x; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index e867e96f03..eb93826e71 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -2032,7 +2032,7 @@ void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION* { highlightInternal( aItem, aMode, aGroup, false ); - view()->Update( aItem ); + view()->Update( aItem, KIGFX::REPAINT ); // Many selections are very temporal and updating the display each time just // creates noise. @@ -2083,7 +2083,7 @@ void SELECTION_TOOL::unhighlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION { unhighlightInternal( aItem, aMode, aGroup, false ); - view()->Update( aItem ); + view()->Update( aItem, KIGFX::REPAINT ); // Many selections are very temporal and updating the display each time just // creates noise. @@ -2110,7 +2110,7 @@ void SELECTION_TOOL::unhighlightInternal( BOARD_ITEM* aItem, int aMode, // N.B. if we clear the selection flag for sub-elements, we need to also // remove the element from the selection group (if it exists) if( isChild ) - view()->Update( aItem ); + view()->Update( aItem, KIGFX::REPAINT ); } // footprints are treated in a special way - when they are highlighted, we have to