7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-04 23:05:30 +00:00

Speed up the time it takes to GeneratePaths

The loop processes nodes but skips those nodes that share the same
parent.  Because of this, we can get strong performance improvement from
caching gains by sorting the vector first by the parents so that the
inner loop is able to skip ahead without invalidating its cache
This commit is contained in:
Seth Hillbrand 2025-02-18 17:57:14 -08:00
parent d2f780dfb4
commit 9781da51e1

View File

@ -2281,6 +2281,13 @@ void CREEPAGE_GRAPH::GeneratePaths( double aMaxWeight, PCB_LAYER_ID aLayer, bool
&& ( gn->m_type != GRAPH_NODE::TYPE::VIRTUAL );
} );
std::sort( nodes.begin(), nodes.end(),
[]( std::shared_ptr<GRAPH_NODE> gn1, std::shared_ptr<GRAPH_NODE> gn2 )
{
return ( gn1->m_parent < gn2->m_parent ) || ( gn1->m_parent == gn2->m_parent
&& gn1->m_net < gn2->m_net );
} );
auto processNodes = [&]( size_t i, size_t j ) -> bool
{
for( size_t ii = i; ii < j; ii++ )