Fixing the problem of (sometimes) slow transient selection (edit mode, top level selection only, large and interleaving arrays)

This commit is contained in:
Matthias Koefferlein 2024-11-25 08:19:05 +01:00 committed by Matthias Koefferlein
parent 33d1cdc545
commit e533a34a08
2 changed files with 21 additions and 10 deletions

View File

@ -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 <db::CellInst, false> 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<double>::max ();

View File

@ -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);