mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-24 21:04:46 +02:00
1aa78cdab6clusterlin: adopt STL ranges algorithms (refactor) (Pieter Wuille)747da25360feefrac: drop comparison and operator{<<,>>} for sorted wrappers (Pieter Wuille) Pull request description: Instead of having an unintuitive but strong implicit sort order on `FeeFrac` (first increasing feerate, then decreasing size), and separate overloaded `operator<<` and `operator>>` that implement a weak ordering that only looks at feerate, replace these with explicit wrapper classes which make the behavior more explicit (`ByRatio` and `ByRatioNegSize`). This allows for things like `ByRatio{a} <= ByRatio{b}`, instead of the earlier `!(a >> b)`. It also supports usage inside `std::min`/`std::max`/`std::less`, and `std::greater`, so one can use: * `std::max<ByRatioNegSize<FeeFrac>>(a, b)` to get the highest-feerate `FeeFrac`, tie-breaking by smallest size. * `std::ranges::sort(v, std::greater<ByRatioNegSize<FeeFrac>>{});` to sort a vector that way. Suggested in https://github.com/bitcoin/bitcoin/pull/34257#discussion_r2780475893. ACKs for top commit: achow101: ACK1aa78cdab6sedited: ACK1aa78cdab6ajtowns: ACK1aa78cdab6Tree-SHA512: d76657b15f6d745e5ca01c67fd5b101fdc418e6301646d14e575b6564bfa2fe0eb40a95a7ff95a4420624ef6b67224d35e4713aa5bbc0d293e08fe44c0cc6db0