diff --git a/src/db/db/dbNet.h b/src/db/db/dbNet.h index 39227c3a7..ada3e98e2 100644 --- a/src/db/db/dbNet.h +++ b/src/db/db/dbNet.h @@ -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 */ diff --git a/src/laybasic/laybasic/layIndexedNetlistModel.cc b/src/laybasic/laybasic/layIndexedNetlistModel.cc index 522bbae61..3a1ba56cd 100644 --- a/src/laybasic/laybasic/layIndexedNetlistModel.cc +++ b/src/laybasic/laybasic/layIndexedNetlistModel.cc @@ -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 () (a->pin (), b->pin ()); } };