7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 19:59:18 +00:00

Performance.

This commit is contained in:
Jeff Young 2025-03-23 20:33:22 +00:00
parent d205a136a9
commit 0a4533703c
34 changed files with 73 additions and 74 deletions

View File

@ -780,7 +780,7 @@ LSET GERBVIEW_FRAME::GetVisibleLayers() const
}
void GERBVIEW_FRAME::SetVisibleLayers( LSET aLayerMask )
void GERBVIEW_FRAME::SetVisibleLayers( const LSET& aLayerMask )
{
if( GetCanvas() )
{

View File

@ -117,7 +117,7 @@ public:
*
* @param aLayerMask The new set of visible layers
*/
void SetVisibleLayers( LSET aLayerMask );
void SetVisibleLayers( const LSET& aLayerMask );
/**
* Test whether a given layer is visible.

View File

@ -583,7 +583,7 @@ public:
*
* @param aMask = The new bit-mask of enabled layers.
*/
void SetEnabledLayers( LSET aMask );
void SetEnabledLayers( const LSET& aMask );
/**
* Test whether a given layer \a aLayerId is enabled.

View File

@ -337,7 +337,8 @@ public:
* @param aDlgPosition is the position of dialog (default is centered).
* @return the selected layer id.
*/
PCB_LAYER_ID SelectOneLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask = LSET(),
PCB_LAYER_ID SelectOneLayer( PCB_LAYER_ID aDefaultLayer,
const LSET& aNotAllowedLayersMask = LSET(),
wxPoint aDlgPosition = wxDefaultPosition );
/**

View File

@ -117,7 +117,7 @@ public:
void SetLayerName( const wxString& aLayerName ) { m_layerName = aLayerName; }
LSET GetPrintLayers() const { return m_printLayers; }
void SetPrintLayers( LSET aLayerSet ) { m_printLayers = aLayerSet; }
void SetPrintLayers( const LSET& aLayerSet ) { m_printLayers = aLayerSet; }
/**
* Clear the list of active layers.

View File

@ -251,7 +251,7 @@ bool AR_AUTOPLACER::fillMatrix()
}
void AR_AUTOPLACER::addFpBody( const VECTOR2I& aStart, const VECTOR2I& aEnd, LSET aLayerMask )
void AR_AUTOPLACER::addFpBody( const VECTOR2I& aStart, const VECTOR2I& aEnd, const LSET& aLayerMask )
{
// Add a polygonal shape (rectangle) to m_fpAreaFront and/or m_fpAreaBack
if( aLayerMask[ F_Cu ] )

View File

@ -114,7 +114,7 @@ private:
const PAD* nearestPad( FOOTPRINT* aRefFP, PAD* aRefPad, const VECTOR2I& aOffset );
// Add a polygonal shape (rectangle) to m_fpAreaFront and/or m_fpAreaBack
void addFpBody( const VECTOR2I& aStart, const VECTOR2I& aEnd, LSET aLayerMask );
void addFpBody( const VECTOR2I& aStart, const VECTOR2I& aEnd, const LSET& aLayerMask );
// Add a polygonal shape (rectangle) to m_fpAreaFront and/or m_fpAreaBack
void addPad( PAD* aPad, int aClearance );

View File

@ -437,8 +437,8 @@ void AR_MATRIX::traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int lay
}
void AR_MATRIX::traceFilledCircle(
int cx, int cy, int radius, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic )
void AR_MATRIX::traceFilledCircle( int cx, int cy, int radius, const LSET& aLayerMask, int color,
AR_MATRIX::CELL_OP op_logic )
{
int row, col;
int ux0, uy0, ux1, uy1;
@ -602,7 +602,7 @@ void AR_MATRIX::traceArc( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& a
void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double angle,
LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic )
const LSET& aLayerMask, int color, AR_MATRIX::CELL_OP op_logic )
{
int row, col;
int cx, cy; // Center of rectangle
@ -689,7 +689,7 @@ void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double
}
void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, LSET aLayerMask,
void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, const LSET& aLayerMask,
int color, AR_MATRIX::CELL_OP op_logic )
{
int row, col;
@ -793,8 +793,8 @@ void AR_MATRIX::TraceSegmentPcb( PCB_SHAPE* aShape, int aColor, int aMargin,
* (aKeepOut ... 0). The decreasing value depends on the distance to the first rectangle
* Therefore the cost is high in rect x0,y0 to x1,y1, and decrease outside this rectangle
*/
void AR_MATRIX::CreateKeepOutRectangle(
int ux0, int uy0, int ux1, int uy1, int marge, int aKeepOut, LSET aLayerMask )
void AR_MATRIX::CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int marge,
int aKeepOut, const LSET& aLayerMask )
{
int row, col;
int row_min, row_max, col_min, col_max, pmarge;

View File

@ -112,14 +112,14 @@ public:
void TraceSegmentPcb( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic );
void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int marge, int aKeepOut,
LSET aLayerMask );
const LSET& aLayerMask );
void PlacePad( PAD* aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic );
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double angle, LSET aLayerMask,
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double angle, const LSET& aLayerMask,
int color, AR_MATRIX::CELL_OP op_logic );
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, LSET aLayerMask, int color,
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, const LSET& aLayerMask, int color,
AR_MATRIX::CELL_OP op_logic );
private:
@ -129,7 +129,7 @@ private:
void traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color,
AR_MATRIX::CELL_OP op_logic );
void traceFilledCircle( int cx, int cy, int radius, LSET aLayerMask, int color,
void traceFilledCircle( int cx, int cy, int radius, const LSET& aLayerMask, int color,
AR_MATRIX::CELL_OP op_logic );
void traceArc( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& arcAngle, int lg,

View File

@ -841,7 +841,7 @@ LSET BOARD::GetVisibleLayers() const
}
void BOARD::SetEnabledLayers( LSET aLayerSet )
void BOARD::SetEnabledLayers( const LSET& aLayerSet )
{
GetDesignSettings().SetEnabledLayers( aLayerSet );
}
@ -853,7 +853,7 @@ bool BOARD::IsLayerEnabled( PCB_LAYER_ID aLayer ) const
}
void BOARD::SetVisibleLayers( LSET aLayerSet )
void BOARD::SetVisibleLayers( const LSET& aLayerSet )
{
if( m_project )
m_project->GetLocalSettings().m_VisibleLayers = aLayerSet;
@ -2209,17 +2209,14 @@ int BOARD::SetAreasNetCodesFromNetNames()
}
PAD* BOARD::GetPad( const VECTOR2I& aPosition, LSET aLayerSet ) const
PAD* BOARD::GetPad( const VECTOR2I& aPosition, const LSET& aLayerSet ) const
{
if( !aLayerSet.any() )
aLayerSet = LSET::AllCuMask();
for( FOOTPRINT* footprint : m_footprints )
{
PAD* pad = nullptr;
if( footprint->HitTest( aPosition ) )
pad = footprint->GetPad( aPosition, aLayerSet );
pad = footprint->GetPad( aPosition, aLayerSet.any() ? aLayerSet : LSET::AllCuMask() );
if( pad )
return pad;
@ -2239,7 +2236,7 @@ PAD* BOARD::GetPad( const PCB_TRACK* aTrace, ENDPOINT_T aEndPoint ) const
}
PAD* BOARD::GetPadFast( const VECTOR2I& aPosition, LSET aLayerSet ) const
PAD* BOARD::GetPadFast( const VECTOR2I& aPosition, const LSET& aLayerSet ) const
{
for( FOOTPRINT* footprint : Footprints() )
{
@ -2258,7 +2255,7 @@ PAD* BOARD::GetPadFast( const VECTOR2I& aPosition, LSET aLayerSet ) const
}
PAD* BOARD::GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, LSET aLayerSet ) const
PAD* BOARD::GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, const LSET& aLayerSet ) const
{
// Search aPadList for aPosition
// aPadList is sorted by X then Y values, and a fast binary search is used
@ -2398,9 +2395,9 @@ std::tuple<int, double, double> BOARD::GetTrackLength( const PCB_TRACK& aTrack )
double length = 0.0;
double package_length = 0.0;
auto connectivity = GetBoard()->GetConnectivity();
BOARD_STACKUP& stackup = GetDesignSettings().GetStackupDescriptor();
bool useHeight = GetDesignSettings().m_UseHeightForLengthCalcs;
auto connectivity = GetBoard()->GetConnectivity();
BOARD_STACKUP& stackup = GetDesignSettings().GetStackupDescriptor();
bool useHeight = GetDesignSettings().m_UseHeightForLengthCalcs;
for( BOARD_CONNECTED_ITEM* item : connectivity->GetConnectedItems( &aTrack, EXCLUDE_ZONES ) )
{

View File

@ -616,7 +616,7 @@ public:
*
* @param aLayerMask the new bit-mask of enabled layers.
*/
void SetEnabledLayers( LSET aLayerMask );
void SetEnabledLayers( const LSET& aLayerMask );
void SetLayerSet( const LSET& aLayerMask ) override { SetEnabledLayers( aLayerMask ); }
/**
@ -649,7 +649,7 @@ public:
*
* @param aLayerMask is the new bit-mask of visible layers.
*/
void SetVisibleLayers( LSET aLayerMask );
void SetVisibleLayers( const LSET& aLayerMask );
// these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
// are not stored in the bitmap.
@ -1110,7 +1110,7 @@ public:
* @param aLayerMask A layer or layers to mask the hit test.
* @return A pointer to a PAD object if found or NULL if not found.
*/
PAD* GetPad( const VECTOR2I& aPosition, LSET aLayerMask ) const;
PAD* GetPad( const VECTOR2I& aPosition, const LSET& aLayerMask ) const;
PAD* GetPad( const VECTOR2I& aPosition ) const
{
return GetPad( aPosition, LSET().set() );
@ -1134,7 +1134,7 @@ public:
* @param aLayerMask A layer or layers to mask the hit test.
* @return A pointer to a PAD object if found or NULL if not found.
*/
PAD* GetPadFast( const VECTOR2I& aPosition, LSET aLayerMask ) const;
PAD* GetPadFast( const VECTOR2I& aPosition, const LSET& aLayerMask ) const;
/**
* Locate the pad connected at \a aPosition on \a aLayer starting at list position
@ -1150,7 +1150,7 @@ public:
* @param aLayerMask A layer or layers to mask the hit test.
* @return a PAD object pointer to the connected pad.
*/
PAD* GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, LSET aLayerMask ) const;
PAD* GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, const LSET& aLayerMask ) const;
/**
* First empties then fills the vector with all pads and sorts them by increasing x

View File

@ -1473,16 +1473,16 @@ void BOARD_DESIGN_SETTINGS::SetUserDefinedLayerCount( int aNewLayerCount )
}
void BOARD_DESIGN_SETTINGS::SetEnabledLayers( LSET aMask )
void BOARD_DESIGN_SETTINGS::SetEnabledLayers( const LSET& aMask )
{
m_enabledLayers = aMask;
// Ensures mandatory back and front layers are always enabled regardless of board file
// configuration.
aMask.set( B_Cu ).set( F_Cu )
.set( B_CrtYd ).set( F_CrtYd )
.set( Edge_Cuts )
.set( Margin );
m_enabledLayers = aMask;
m_enabledLayers.set( B_Cu ).set( F_Cu )
.set( B_CrtYd ).set( F_CrtYd )
.set( Edge_Cuts )
.set( Margin );
// update layer counts to ensure their consistency with m_EnabledLayers
LSET copperLayers = aMask;

View File

@ -1349,7 +1349,7 @@ void PANEL_SETUP_BOARD_STACKUP::ImportSettingsFrom( BOARD* aBoard )
}
void PANEL_SETUP_BOARD_STACKUP::OnLayersOptionsChanged( LSET aNewLayerSet )
void PANEL_SETUP_BOARD_STACKUP::OnLayersOptionsChanged( const LSET& aNewLayerSet )
{
// Can be called spuriously from events before the layers page is even created
if( !m_panelLayers->IsInitialized() )

View File

@ -103,7 +103,7 @@ public:
* Rebuild the Layer Stack Panel if the new layer set differs
* from the current layet set
*/
void OnLayersOptionsChanged( LSET aNewLayerSet );
void OnLayersOptionsChanged( const LSET& aNewLayerSet );
/// @return the number of copper layers configured for the board stackup
int GetCopperLayerCount() const;

View File

@ -327,7 +327,7 @@ public:
* @param aVisibleLayerMask is the current visible layers (bit mask).
* @param aPreferredLayer is the layer to search first.
*/
GENERAL_COLLECTORS_GUIDE( LSET aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer,
GENERAL_COLLECTORS_GUIDE( const LSET& aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer,
KIGFX::VIEW* aView )
{
static const VECTOR2I one( 1, 1 );
@ -375,7 +375,7 @@ public:
{
m_visibleLayers.set( aLayerId, isVisible );
}
void SetLayerVisibleBits( LSET aLayerBits ) { m_visibleLayers = aLayerBits; }
void SetLayerVisibleBits( const LSET& aLayerBits ) { m_visibleLayers = aLayerBits; }
/**
* @return int - the preferred layer for HitTest()ing.

View File

@ -151,7 +151,7 @@ void DRC_TEST_PROVIDER::reportRuleStatistics()
}
int DRC_TEST_PROVIDER::forEachGeometryItem( const std::vector<KICAD_T>& aTypes, LSET aLayers,
int DRC_TEST_PROVIDER::forEachGeometryItem( const std::vector<KICAD_T>& aTypes, const LSET& aLayers,
const std::function<bool( BOARD_ITEM*)>& aFunc )
{
BOARD *brd = m_drcEngine->GetBoard();

View File

@ -102,7 +102,7 @@ public:
virtual const wxString GetDescription() const;
protected:
int forEachGeometryItem( const std::vector<KICAD_T>& aTypes, LSET aLayers,
int forEachGeometryItem( const std::vector<KICAD_T>& aTypes, const LSET& aLayers,
const std::function<bool(BOARD_ITEM*)>& aFunc );
// Do not use a wxString with a vararg list: it is a complex thing and can create issues.

View File

@ -107,7 +107,7 @@ static wxString escapeString( const wxString& aString )
}
static std::string fmt_mask( LSET aSet )
static std::string fmt_mask( const LSET& aSet )
{
return ( aSet & LSET::AllCuMask() ).to_string();
}

View File

@ -1454,7 +1454,7 @@ const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText ) const
}
const BOX2I FOOTPRINT::GetLayerBoundingBox( LSET aLayers ) const
const BOX2I FOOTPRINT::GetLayerBoundingBox( const LSET& aLayers ) const
{
std::vector<PCB_TEXT*> texts;
const BOARD* board = GetBoard();
@ -1943,7 +1943,7 @@ PAD* FOOTPRINT::FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe
}
PAD* FOOTPRINT::GetPad( const VECTOR2I& aPosition, LSET aLayerMask )
PAD* FOOTPRINT::GetPad( const VECTOR2I& aPosition, const LSET& aLayerMask )
{
for( PAD* pad : m_pads )
{

View File

@ -144,7 +144,7 @@ public:
}
LSET GetPrivateLayers() const { return m_privateLayers; }
void SetPrivateLayers( LSET aLayers ) { m_privateLayers = aLayers; }
void SetPrivateLayers( const LSET& aLayers ) { m_privateLayers = aLayers; }
///< @copydoc BOARD_ITEM_CONTAINER::Add()
void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
@ -199,7 +199,7 @@ public:
/**
* Return the bounding box of the footprint on a given set of layers
*/
const BOX2I GetLayerBoundingBox( LSET aLayers ) const;
const BOX2I GetLayerBoundingBox( const LSET& aLayers ) const;
VECTOR2I GetCenter() const override { return GetBoundingBox( false ).GetCenter(); }
@ -769,7 +769,7 @@ public:
* @param aLayerMask A layer or layers to mask the hit test.
* @return A pointer to a #PAD object if found otherwise NULL.
*/
PAD* GetPad( const VECTOR2I& aPosition, LSET aLayerMask = LSET::AllLayersMask() );
PAD* GetPad( const VECTOR2I& aPosition, const LSET& aLayerMask = LSET::AllLayersMask() );
std::vector<const PAD*> GetPads( const wxString& aPadNumber,
const PAD* aIgnore = nullptr ) const;

View File

@ -110,7 +110,7 @@ void GRID_CELL_LAYER_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC&
// Note: this implementation is an adaptation of wxGridCellChoiceEditor
GRID_CELL_LAYER_SELECTOR::GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, LSET aMask,
GRID_CELL_LAYER_SELECTOR::GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, const LSET& aMask,
bool aShowNonActivated ) :
m_frame( aFrame ),
m_mask( aMask ),

View File

@ -56,7 +56,7 @@ private:
class GRID_CELL_LAYER_SELECTOR : public wxGridCellEditor
{
public:
GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, LSET forbiddenLayers,
GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, const LSET& forbiddenLayers,
bool aShowNonActivated = false );
wxGridCellEditor* Clone() const override;

View File

@ -330,7 +330,7 @@ PCB_LAYER_ID PAD::GetPrincipalLayer() const
}
bool PAD::FlashLayer( LSET aLayers ) const
bool PAD::FlashLayer( const LSET& aLayers ) const
{
for( PCB_LAYER_ID layer : aLayers.Seq() )
{

View File

@ -814,7 +814,7 @@ public:
* @return true if connected by pad or track (or optionally zone) on any of the associated
* layers
*/
bool FlashLayer( LSET aLayers ) const;
bool FlashLayer( const LSET& aLayers ) const;
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;

View File

@ -54,7 +54,7 @@ public:
void SetBoardFrame( PCB_BASE_FRAME* aFrame );
// SetLayerSet allows disabling some layers, which are not shown in list
void SetNotAllowedLayerSet( LSET aMask ) { m_layerMaskDisable = aMask; }
void SetNotAllowedLayerSet( const LSET& aMask ) { m_layerMaskDisable = aMask; }
// If the UNDEFINED_LAYER should be selectable, give it a name here. Usually either
// INDETERMINATE_STATE or INDETERMINATE_ACTION.

Some files were not shown because too many files have changed in this diff Show More