Skip to content

Commit 2ef561b

Browse files
authored
Merge pull request #8636 from gadfort/odb-speedup-merge
odb: dont add each polygon to set, add them in bulk
2 parents e56b51d + 9ae84d9 commit 2ef561b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/odb/src/db/dbBlock.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,7 @@ const std::vector<Rect>& dbBlock::getBlockedRegionsForPins()
23322332
Polygon dbBlock::computeCoreArea()
23332333
{
23342334
std::vector<odb::Rect> rows;
2335+
rows.reserve(getRows().size());
23352336
for (dbRow* row : getRows()) {
23362337
if (row->getSite()->getClass() != odb::dbSiteClass::PAD) {
23372338
rows.push_back(row->getBBox());

src/odb/src/db/geom.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,16 @@ std::vector<Polygon> Polygon::merge(const std::vector<Polygon>& polys)
7070
using BoostPolygonSet = boost::polygon::polygon_set_data<int>;
7171
using boost::polygon::operators::operator+=;
7272

73-
// add to polygon set
74-
BoostPolygonSet poly_in_set;
75-
73+
// convert to boost polygon
74+
std::vector<BoostPolygon> boost_poly;
75+
boost_poly.reserve(polys.size());
7676
for (const Polygon& poly : polys) {
77-
// convert to boost polygon
78-
const BoostPolygon polygon_in(poly.points_.begin(), poly.points_.end());
79-
poly_in_set += polygon_in;
77+
boost_poly.emplace_back(poly.points_.begin(), poly.points_.end());
8078
}
8179

80+
// add to polygon set
81+
const BoostPolygonSet poly_in_set(boost_poly.begin(), boost_poly.end());
82+
8283
// extract new polygons
8384
std::vector<BoostPolygon> output_polygons;
8485
poly_in_set.get(output_polygons);

0 commit comments

Comments
 (0)