From e533a34a081784a5d781b2af03ffdcdaa006fe30 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 25 Nov 2024 08:19:05 +0100 Subject: [PATCH] Fixing the problem of (sometimes) slow transient selection (edit mode, top level selection only, large and interleaving arrays) --- src/laybasic/laybasic/layFinder.cc | 22 +++++++++++++--------- src/laybasic/laybasic/layFinder.h | 9 ++++++++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/laybasic/laybasic/layFinder.cc b/src/laybasic/laybasic/layFinder.cc index b874cff6c..0b3303d05 100644 --- a/src/laybasic/laybasic/layFinder.cc +++ b/src/laybasic/laybasic/layFinder.cc @@ -235,6 +235,8 @@ Finder::do_find (const db::Cell &cell, int level, const db::DCplxTrans &vp, cons m_path.push_back (db::InstElement (*inst, p)); + checkpoint (); + do_find (mp_layout->cell (cell_inst.object ().cell_index ()), level + 1, vp, @@ -772,6 +774,14 @@ InstFinder::find_internal (LayoutViewBase *view, unsigned int cv_index, const db return ! m_founds.empty (); } +void +InstFinder::checkpoint () +{ + if (--m_tries < 0) { + throw StopException (); + } +} + void InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const db::Box & /*scan_box*/, const db::DCplxTrans & /*vp*/, const db::ICplxTrans &t, int level) { @@ -854,17 +864,13 @@ InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const d } else { - if (--m_tries < 0) { - throw StopException (); - } + checkpoint (); // look for instances to check here .. db::Cell::touching_iterator inst = cell.begin_touching (search_box); while (! inst.at_end ()) { - if (--m_tries < 0) { - throw StopException (); - } + checkpoint (); const db::CellInstArray &cell_inst = inst->cell_inst (); const db::Cell &inst_cell = layout ().cell (cell_inst.object ().cell_index ()); @@ -877,9 +883,7 @@ InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const d db::box_convert bc (layout ()); for (db::CellInstArray::iterator p = cell_inst.begin_touching (search_box, bc); ! p.at_end (); ++p) { - if (--m_tries < 0) { - throw StopException (); - } + checkpoint (); bool match = false; double d = std::numeric_limits::max (); diff --git a/src/laybasic/laybasic/layFinder.h b/src/laybasic/laybasic/layFinder.h index 0346f305b..b5edeaa71 100644 --- a/src/laybasic/laybasic/layFinder.h +++ b/src/laybasic/laybasic/layFinder.h @@ -189,6 +189,11 @@ protected: */ void test_edge (const db::ICplxTrans &trans, const db::Edge &edge, double &distance, bool &match); + /** + * @brief Is called "frequently", so the finder can stop after a number of tries and not waste time + */ + virtual void checkpoint () = 0; + private: void do_find (const db::Cell &cell, int level, const db::DCplxTrans &vp, const db::ICplxTrans &t); @@ -282,7 +287,7 @@ protected: m_tries = n; } - void checkpoint (); + virtual void checkpoint (); private: virtual void visit_cell (const db::Cell &cell, const db::Box &hit_box, const db::Box &scan_box, const db::DCplxTrans &vp, const db::ICplxTrans &t, int level); @@ -339,6 +344,8 @@ public: return m_founds.end (); } + virtual void checkpoint (); + private: virtual void visit_cell (const db::Cell &cell, const db::Box &hit_box, const db::Box &scan_box, const db::DCplxTrans &vp, const db::ICplxTrans &t, int level);