Marginal performance improvements.
This commit is contained in:
parent
f99761e5bd
commit
86944c4f9f
|
@ -105,7 +105,10 @@ namespace std
|
||||||
{
|
{
|
||||||
std::size_t operator()( const PTR_PTR_CACHE_KEY& k ) const
|
std::size_t operator()( const PTR_PTR_CACHE_KEY& k ) const
|
||||||
{
|
{
|
||||||
return hash<void*>()( k.A ) ^ hash<void*>()( k.B );
|
constexpr std::size_t prime = 2166136261u;
|
||||||
|
|
||||||
|
return reinterpret_cast<uintptr_t>( k.A ) * prime
|
||||||
|
^ reinterpret_cast<uintptr_t>( k.B ) * prime;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,9 +117,10 @@ namespace std
|
||||||
{
|
{
|
||||||
std::size_t operator()( const PTR_LAYER_CACHE_KEY& k ) const
|
std::size_t operator()( const PTR_LAYER_CACHE_KEY& k ) const
|
||||||
{
|
{
|
||||||
constexpr std::size_t prime = 19937;
|
constexpr std::size_t prime = 2166136261u;
|
||||||
|
|
||||||
return hash<void*>()( k.A ) ^ ( hash<int>()( k.Layer ) * prime );
|
return reinterpret_cast<uintptr_t>( k.A ) * prime
|
||||||
|
^ hash<int>()( k.Layer ) * prime;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,9 +129,11 @@ namespace std
|
||||||
{
|
{
|
||||||
std::size_t operator()( const PTR_PTR_LAYER_CACHE_KEY& k ) const
|
std::size_t operator()( const PTR_PTR_LAYER_CACHE_KEY& k ) const
|
||||||
{
|
{
|
||||||
constexpr std::size_t prime = 19937;
|
constexpr std::size_t prime = 2166136261u;
|
||||||
|
|
||||||
return hash<void*>()( k.A ) ^ hash<void*>()( k.B ) ^ ( hash<int>()( k.Layer ) * prime );
|
return reinterpret_cast<uintptr_t>( k.A ) * prime
|
||||||
|
^ reinterpret_cast<uintptr_t>( k.B ) * prime
|
||||||
|
^ hash<int>()( k.Layer ) * prime;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <geometry/shape_segment.h>
|
#include <geometry/shape_segment.h>
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
#include "geometry/shape_null.h"
|
#include "geometry/shape_null.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement an R-tree for fast spatial and layer indexing of connectable items.
|
* Implement an R-tree for fast spatial and layer indexing of connectable items.
|
||||||
|
@ -208,21 +209,19 @@ public:
|
||||||
* clearance. It's used when looking up the specific item-to-item clearance might be
|
* clearance. It's used when looking up the specific item-to-item clearance might be
|
||||||
* expensive and should be deferred till we know we have a possible hit.
|
* expensive and should be deferred till we know we have a possible hit.
|
||||||
*/
|
*/
|
||||||
int QueryColliding( BOARD_ITEM* aRefItem,
|
int QueryColliding( BOARD_ITEM* aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer,
|
||||||
PCB_LAYER_ID aRefLayer,
|
|
||||||
PCB_LAYER_ID aTargetLayer,
|
|
||||||
std::function<bool( BOARD_ITEM* )> aFilter = nullptr,
|
std::function<bool( BOARD_ITEM* )> aFilter = nullptr,
|
||||||
std::function<bool( BOARD_ITEM* )> aVisitor = nullptr,
|
std::function<bool( BOARD_ITEM* )> aVisitor = nullptr,
|
||||||
int aClearance = 0 ) const
|
int aClearance = 0 ) const
|
||||||
{
|
{
|
||||||
// keep track of BOARD_ITEMs that have been already found to collide (some items
|
// keep track of BOARD_ITEMs that have already been found to collide (some items might
|
||||||
// might be build of COMPOUND/triangulated shapes and a single subshape collision
|
// be built of COMPOUND/triangulated shapes and a single subshape collision means we have
|
||||||
// means we have a hit)
|
// a hit)
|
||||||
std::unordered_set<BOARD_ITEM*> collidingCompounds;
|
std::unordered_set<BOARD_ITEM*> collidingCompounds;
|
||||||
|
|
||||||
// keep track of results of client filter so we don't ask more than once for compound
|
// keep track of results of client filter so we don't ask more than once for compound
|
||||||
// shapes
|
// shapes
|
||||||
std::map<BOARD_ITEM*, bool> filterResults;
|
std::unordered_map<BOARD_ITEM*, bool> filterResults;
|
||||||
|
|
||||||
EDA_RECT box = aRefItem->GetBoundingBox();
|
EDA_RECT box = aRefItem->GetBoundingBox();
|
||||||
box.Inflate( aClearance );
|
box.Inflate( aClearance );
|
||||||
|
@ -394,9 +393,10 @@ public:
|
||||||
* @param aLayer Layer to search
|
* @param aLayer Layer to search
|
||||||
* @return vector of overlapping BOARD_ITEMS*
|
* @return vector of overlapping BOARD_ITEMS*
|
||||||
*/
|
*/
|
||||||
std::set<BOARD_ITEM*> GetObjectsAt( const VECTOR2I& aPt, PCB_LAYER_ID aLayer, int aClearance = 0 )
|
std::unordered_set<BOARD_ITEM*> GetObjectsAt( const VECTOR2I& aPt, PCB_LAYER_ID aLayer,
|
||||||
|
int aClearance = 0 )
|
||||||
{
|
{
|
||||||
std::set<BOARD_ITEM*> retval;
|
std::unordered_set<BOARD_ITEM*> retval;
|
||||||
int min[2] = { aPt.x - aClearance, aPt.y - aClearance };
|
int min[2] = { aPt.x - aClearance, aPt.y - aClearance };
|
||||||
int max[2] = { aPt.x + aClearance, aPt.y + aClearance };
|
int max[2] = { aPt.x + aClearance, aPt.y + aClearance };
|
||||||
|
|
||||||
|
@ -427,11 +427,9 @@ public:
|
||||||
ITEM_WITH_SHAPE* testItem;
|
ITEM_WITH_SHAPE* testItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
int QueryCollidingPairs( DRC_RTREE* aRefTree,
|
int QueryCollidingPairs( DRC_RTREE* aRefTree, std::vector<LAYER_PAIR> aLayerPairs,
|
||||||
std::vector<LAYER_PAIR> aLayerPairs,
|
std::function<bool( const LAYER_PAIR&, ITEM_WITH_SHAPE*,
|
||||||
std::function<bool( const LAYER_PAIR&,
|
ITEM_WITH_SHAPE*, bool* aCollision )> aVisitor,
|
||||||
ITEM_WITH_SHAPE*, ITEM_WITH_SHAPE*,
|
|
||||||
bool* aCollision )> aVisitor,
|
|
||||||
int aMaxClearance,
|
int aMaxClearance,
|
||||||
std::function<bool(int, int )> aProgressReporter ) const
|
std::function<bool(int, int )> aProgressReporter ) const
|
||||||
{
|
{
|
||||||
|
@ -468,7 +466,7 @@ public:
|
||||||
// keep track of BOARD_ITEMs pairs that have been already found to collide (some items
|
// keep track of BOARD_ITEMs pairs that have been already found to collide (some items
|
||||||
// might be build of COMPOUND/triangulated shapes and a single subshape collision
|
// might be build of COMPOUND/triangulated shapes and a single subshape collision
|
||||||
// means we have a hit)
|
// means we have a hit)
|
||||||
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, int> collidingCompounds;
|
std::unordered_map<PTR_PTR_CACHE_KEY, int> collidingCompounds;
|
||||||
|
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
int count = pairsToVisit.size();
|
int count = pairsToVisit.size();
|
||||||
|
|
|
@ -454,7 +454,7 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances()
|
||||||
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
||||||
std::swap( a, b );
|
std::swap( a, b );
|
||||||
|
|
||||||
if( checkedPairs.count( { a, b } ) )
|
if( checkedPairs.find( { a, b } ) != checkedPairs.end() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -721,7 +721,7 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances( )
|
||||||
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
||||||
std::swap( a, b );
|
std::swap( a, b );
|
||||||
|
|
||||||
if( checkedPairs.count( { a, b } ) )
|
if( checkedPairs.find( { a, b } ) != checkedPairs.end() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ bool DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run()
|
||||||
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
||||||
std::swap( a, b );
|
std::swap( a, b );
|
||||||
|
|
||||||
if( checkedPairs.count( { a, b } ) )
|
if( checkedPairs.find( { a, b } ) != checkedPairs.end() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ bool DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run()
|
||||||
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
||||||
std::swap( a, b );
|
std::swap( a, b );
|
||||||
|
|
||||||
if( checkedPairs.count( { a, b } ) )
|
if( checkedPairs.find( { a, b } ) != checkedPairs.end() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run()
|
||||||
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
||||||
std::swap( a, b );
|
std::swap( a, b );
|
||||||
|
|
||||||
if( checkedPairs.count( { a, b } ) )
|
if( checkedPairs.find( { a, b } ) != checkedPairs.end() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,12 +451,11 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems( BOARD_ITEM* aItem,
|
||||||
BOARD_ITEM* a = aItem;
|
BOARD_ITEM* a = aItem;
|
||||||
BOARD_ITEM* b = other;
|
BOARD_ITEM* b = other;
|
||||||
|
|
||||||
// store canonical order so we don't collide in both directions
|
// store canonical order so we don't collide in both directions (a:b and b:a)
|
||||||
// (a:b and b:a)
|
|
||||||
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
||||||
std::swap( a, b );
|
std::swap( a, b );
|
||||||
|
|
||||||
if( m_checkedPairs.count( { a, b, aTargetLayer } ) )
|
if( m_checkedPairs.find( { a, b, aTargetLayer } ) != m_checkedPairs.end() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2368,11 +2368,7 @@ void FOOTPRINT::CheckOverlappingPads( const std::function<void( const PAD*, cons
|
||||||
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
if( static_cast<void*>( a ) > static_cast<void*>( b ) )
|
||||||
std::swap( a, b );
|
std::swap( a, b );
|
||||||
|
|
||||||
if( checkedPairs.count( { a, b } ) )
|
if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
checkedPairs[ { a, b } ] = 1;
|
checkedPairs[ { a, b } ] = 1;
|
||||||
|
|
||||||
|
@ -2530,13 +2526,13 @@ void FOOTPRINT::CheckNetTiePadGroups( const std::function<void( const wxString&
|
||||||
{
|
{
|
||||||
aErrorHandler( wxString::Format( _( "(net-tie pad group contains unknown pad "
|
aErrorHandler( wxString::Format( _( "(net-tie pad group contains unknown pad "
|
||||||
"number %s)" ),
|
"number %s)" ),
|
||||||
padNumber ) );
|
padNumber ) );
|
||||||
}
|
}
|
||||||
else if( !padNumbers.insert( padNumber ).second )
|
else if( !padNumbers.insert( padNumber ).second )
|
||||||
{
|
{
|
||||||
aErrorHandler( wxString::Format( _( "(pad %s appears in more than one net-tie "
|
aErrorHandler( wxString::Format( _( "(pad %s appears in more than one net-tie "
|
||||||
"pad group)" ),
|
"pad group)" ),
|
||||||
padNumber ) );
|
padNumber ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue