Skip to content

Commit

Permalink
Simplify 'request_lt' (for idx == 0)
Browse files Browse the repository at this point in the history
  • Loading branch information
SSoelvsten committed Nov 28, 2023
1 parent 9807e91 commit 35e9873
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/adiar/internal/data_types/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,23 +359,15 @@ namespace adiar::internal
template<typename Request, size_t idx = 0>
struct request_lt
{
static_assert(idx == 0, "Non-lexicographical ordering not (yet) supported.");

/// \copydoc request_lt
inline bool operator()(const Request &a, const Request &b)
{
const typename Request::label_type label_a = a.target.first().label();
const typename Request::label_type label_b = b.target.first().label();

if constexpr (Request::cardinality == 2) {
constexpr size_t o_idx = 1u - idx;

return label_a < label_b
|| (label_a == label_b && a.target[idx] < b.target[idx])
|| (label_a == label_b && a.target[idx] == b.target[idx] && a.target[o_idx] < b.target[o_idx]);
}

return label_a < label_b
|| (label_a == label_b && a.target[idx] < b.target[idx])
|| (label_a == label_b && a.target[idx] == b.target[idx] && a.target < b.target);
return label_a < label_b || (label_a == label_b && a.target < b.target);
}
};

Expand Down

0 comments on commit 35e9873

Please sign in to comment.