From a64726e5aa0b4c1cf0cc2162966eb595f074c370 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 9 Jun 2019 10:05:45 +0200 Subject: [PATCH] Performance enhancement of netlist model (issue was sorting by expanded name) --- src/db/db/dbNet.h | 9 +++++++++ src/laybasic/laybasic/layIndexedNetlistModel.cc | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) 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 ()); } };