Skip to content

Commit 817099e

Browse files
oharboeclaude
andcommitted
dpl: cache hpwl in optimize_mirroring sort comparator
Avoid recomputing hpwl() twice per comparison. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent cd0f4d7 commit 817099e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/dpl/src/OptMirror.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ void OptimizeMirroring::run()
6565
// Sort net boxes by net hpwl.
6666
std::ranges::sort(
6767
sorted_boxes, [](NetBox* net_box1, NetBox* net_box2) -> bool {
68-
if (net_box1->hpwl() != net_box2->hpwl()) {
69-
return net_box1->hpwl() > net_box2->hpwl();
68+
const int64_t hpwl1 = net_box1->hpwl();
69+
const int64_t hpwl2 = net_box2->hpwl();
70+
if (hpwl1 != hpwl2) {
71+
return hpwl1 > hpwl2;
7072
}
7173
// net_box_map_ is unordered; tie-break for stable output.
7274
return net_box1->getNet()->getId() < net_box2->getNet()->getId();

0 commit comments

Comments
 (0)