Skip to content

Commit 3f0e9c5

Browse files
oharboeclaude
andcommitted
rsz: collapse buffer-size comparator to a make_tuple compare
Per review, express the (cap, id) lexicographic order as a single std::make_tuple comparison. Each key is still evaluated once per cell, and the explicit if-chain goes away. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent dadc151 commit 3f0e9c5

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

src/rsz/src/Rebuffer.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,12 +1500,8 @@ void Rebuffer::init()
15001500
}
15011501

15021502
std::ranges::sort(buffer_sizes_, [=](BufferSize a, BufferSize b) {
1503-
const float cin_a = bufferCin(a.cell);
1504-
const float cin_b = bufferCin(b.cell);
1505-
if (cin_a != cin_b) {
1506-
return cin_a < cin_b;
1507-
}
1508-
return a.cell->id() < b.cell->id();
1503+
return std::make_tuple(bufferCin(a.cell), a.cell->id())
1504+
< std::make_tuple(bufferCin(b.cell), b.cell->id());
15091505
});
15101506

15111507
buffer_sizes_index_.clear();

src/rsz/src/RepairDesign.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <optional>
1515
#include <set>
1616
#include <string>
17+
#include <tuple>
1718
#include <utility>
1819
#include <vector>
1920

@@ -647,12 +648,8 @@ void RepairDesign::findBufferSizes()
647648
resizer_->buffer_fast_sizes_.end()};
648649
std::ranges::sort(buffer_sizes_,
649650
[=](sta::LibertyCell* a, sta::LibertyCell* b) {
650-
const float cin_a = bufferCin(a);
651-
const float cin_b = bufferCin(b);
652-
if (cin_a != cin_b) {
653-
return cin_a < cin_b;
654-
}
655-
return a->id() < b->id();
651+
return std::make_tuple(bufferCin(a), a->id())
652+
< std::make_tuple(bufferCin(b), b->id());
656653
});
657654
}
658655

0 commit comments

Comments
 (0)