Minor performance fixes for PCBNew selections.

This commit is contained in:
Jeff Young 2020-11-19 17:23:02 +00:00
parent 04c84fa842
commit 876b87b64e
2 changed files with 10 additions and 5 deletions

View File

@ -332,6 +332,9 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText )
bool in_super_or_subscript = false; bool in_super_or_subscript = false;
VECTOR2D glyphSize = baseGlyphSize; VECTOR2D glyphSize = baseGlyphSize;
// Allocate only once (for performance)
std::deque<VECTOR2D> ptListScaled;
yOffset = 0; yOffset = 0;
for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt ) 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<VECTOR2D>* ptList : *glyph ) for( const std::vector<VECTOR2D>* ptList : *glyph )
{ {
std::deque<VECTOR2D> ptListScaled; int ptCount = 0;
ptListScaled.clear();
for( const VECTOR2D& pt : *ptList ) for( const VECTOR2D& pt : *ptList )
{ {
@ -473,9 +477,10 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText )
} }
ptListScaled.push_back( scaledPt ); ptListScaled.push_back( scaledPt );
ptCount++;
} }
m_gal->DrawPolyline( ptListScaled ); m_gal->DrawPolyline( &ptListScaled[0], ptCount );
} }
xOffset += glyphSize.x * bbox.GetEnd().x; xOffset += glyphSize.x * bbox.GetEnd().x;

View File

@ -2032,7 +2032,7 @@ void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION*
{ {
highlightInternal( aItem, aMode, aGroup, false ); 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 // Many selections are very temporal and updating the display each time just
// creates noise. // creates noise.
@ -2083,7 +2083,7 @@ void SELECTION_TOOL::unhighlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION
{ {
unhighlightInternal( aItem, aMode, aGroup, false ); 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 // Many selections are very temporal and updating the display each time just
// creates noise. // 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 // 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) // remove the element from the selection group (if it exists)
if( isChild ) if( isChild )
view()->Update( aItem ); view()->Update( aItem, KIGFX::REPAINT );
} }
// footprints are treated in a special way - when they are highlighted, we have to // footprints are treated in a special way - when they are highlighted, we have to