mirror of https://github.com/KLayout/klayout.git
Added some unit tests for performance improvement of queries.
This commit is contained in:
parent
0dcfeabaf4
commit
dfd713016b
|
|
@ -513,7 +513,7 @@ public:
|
||||||
bool cell_matches (db::cell_index_type ci)
|
bool cell_matches (db::cell_index_type ci)
|
||||||
{
|
{
|
||||||
// prefilter with the cell objectives
|
// prefilter with the cell objectives
|
||||||
if (! objectives ().wants_all_cells () && ! objectives ().wants_cell (ci)) {
|
if (! objectives ().wants_cell (ci)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2960,6 +2960,10 @@ FilterStateObjectives::operator+= (const FilterStateObjectives &other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_wants_all_cells) {
|
||||||
|
m_wants_cells.clear ();
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2981,7 +2985,7 @@ FilterStateObjectives::request_cell (db::cell_index_type ci)
|
||||||
bool
|
bool
|
||||||
FilterStateObjectives::wants_cell (db::cell_index_type ci) const
|
FilterStateObjectives::wants_cell (db::cell_index_type ci) const
|
||||||
{
|
{
|
||||||
return m_wants_cells.find (ci) != m_wants_cells.end ();
|
return m_wants_all_cells || m_wants_cells.find (ci) != m_wants_cells.end ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,52 @@ static std::string q2s_cell (db::LayoutQueryIterator &iq, const std::string &pna
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(1)
|
TEST(0)
|
||||||
|
{
|
||||||
|
// FilterStateObjectives tests
|
||||||
|
db::FilterStateObjectives o1;
|
||||||
|
|
||||||
|
EXPECT_EQ (o1.wants_all_cells (), false);
|
||||||
|
o1.set_wants_all_cells (true);
|
||||||
|
EXPECT_EQ (o1.wants_cell (db::cell_index_type (17)), true);
|
||||||
|
EXPECT_EQ (o1.wants_all_cells (), true);
|
||||||
|
|
||||||
|
o1.set_wants_all_cells (false);
|
||||||
|
o1.request_cell (db::cell_index_type (17));
|
||||||
|
EXPECT_EQ (o1.wants_all_cells (), false);
|
||||||
|
EXPECT_EQ (o1.wants_cell (db::cell_index_type (17)), true);
|
||||||
|
EXPECT_EQ (o1.wants_cell (db::cell_index_type (16)), false);
|
||||||
|
|
||||||
|
db::FilterStateObjectives o2 = o1;
|
||||||
|
|
||||||
|
o1.set_wants_all_cells (false);
|
||||||
|
EXPECT_EQ (o1.wants_cell (db::cell_index_type (17)), false);
|
||||||
|
|
||||||
|
EXPECT_EQ (o2.wants_cell (db::cell_index_type (17)), true);
|
||||||
|
|
||||||
|
db::FilterStateObjectives o3 = o2;
|
||||||
|
|
||||||
|
EXPECT_EQ (o3.wants_cell (db::cell_index_type (17)), true);
|
||||||
|
o3 += db::FilterStateObjectives::everything ();
|
||||||
|
EXPECT_EQ (o3.wants_all_cells (), true);
|
||||||
|
|
||||||
|
o3 = db::FilterStateObjectives::everything ();
|
||||||
|
EXPECT_EQ (o3.wants_all_cells (), true);
|
||||||
|
o3 += o2;
|
||||||
|
EXPECT_EQ (o3.wants_all_cells (), true);
|
||||||
|
|
||||||
|
o3 = db::FilterStateObjectives ();
|
||||||
|
EXPECT_EQ (o3.wants_all_cells (), false);
|
||||||
|
o3.request_cell (db::cell_index_type (16));
|
||||||
|
EXPECT_EQ (o3.wants_cell (db::cell_index_type (17)), false);
|
||||||
|
EXPECT_EQ (o3.wants_cell (db::cell_index_type (16)), true);
|
||||||
|
o3 += o2;
|
||||||
|
EXPECT_EQ (o3.wants_all_cells (), false);
|
||||||
|
EXPECT_EQ (o3.wants_cell (db::cell_index_type (17)), true);
|
||||||
|
EXPECT_EQ (o3.wants_cell (db::cell_index_type (16)), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(1)
|
||||||
{
|
{
|
||||||
db::Layout g;
|
db::Layout g;
|
||||||
g.insert_layer (0);
|
g.insert_layer (0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue