Performance enhancement of netlist model (issue was sorting by expanded name)

This commit is contained in:
Matthias Koefferlein 2019-06-09 10:05:45 +02:00
parent 13f4547789
commit a64726e5aa
2 changed files with 20 additions and 2 deletions

View File

@ -467,6 +467,15 @@ public:
return m_cluster_id;
}
/**
* @brief Provided for API compatibility with the other objects
* This ID is not well-formed like for other objects.
*/
size_t id () const
{
return m_cluster_id;
}
/**
* @brief Adds a pin to this net
*/

View File

@ -46,7 +46,16 @@ namespace {
{
inline bool operator() (const Obj *a, const Obj *b) const
{
return a->expanded_name () < b->expanded_name ();
// NOTE: we don't use expanded_name () for performance
if (a->name ().empty () != b->name ().empty ()) {
// named ones first
return a->name ().empty () < b->name ().empty ();
}
if (a->name ().empty ()) {
return a->id () < b->id ();
} else {
return a->name () < b->name ();
}
}
};
@ -55,7 +64,7 @@ namespace {
{
inline bool operator() (const Obj *a, const Obj *b) const
{
return a->pin ()->expanded_name () < b->pin ()->expanded_name ();
return sort_single_by_expanded_name<db::Pin> () (a->pin (), b->pin ());
}
};