Skip to content

Commit b3a178e

Browse files
oharboeclaude
andcommitted
rsz: direct compare in buffer-size comparator, drop make_tuple
Per review, the std::make_tuple temporaries add overhead and pull in <tuple>; use a direct (cap, id) compare with cached bufferCin locals instead, matching the explicit comparator style in Resizer.cc. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 3f0e9c5 commit b3a178e

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/rsz/src/Rebuffer.cc

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

15021502
std::ranges::sort(buffer_sizes_, [=](BufferSize a, BufferSize b) {
1503-
return std::make_tuple(bufferCin(a.cell), a.cell->id())
1504-
< std::make_tuple(bufferCin(b.cell), b.cell->id());
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();
15051509
});
15061510

15071511
buffer_sizes_index_.clear();

src/rsz/src/RepairDesign.cc

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

@@ -648,8 +647,12 @@ void RepairDesign::findBufferSizes()
648647
resizer_->buffer_fast_sizes_.end()};
649648
std::ranges::sort(buffer_sizes_,
650649
[=](sta::LibertyCell* a, sta::LibertyCell* b) {
651-
return std::make_tuple(bufferCin(a), a->id())
652-
< std::make_tuple(bufferCin(b), b->id());
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();
653656
});
654657
}
655658

0 commit comments

Comments
 (0)