[QUEUED scylla next] serialized_tri_compare: change to std::strong_ordering

0 views
Skip to first unread message

Commit Bot

unread,
Jul 29, 2021, 3:44:18 PMJul 29
to scylla...@googlegroups.com, Avi Kivity
From: Avi Kivity <a...@scylladb.com>
Committer: Avi Kivity <a...@scylladb.com>
Branch: next

serialized_tri_compare: change to std::strong_ordering

Also convert a users in mutation_test.

Ref #1449.

---
diff --git a/test/boost/mutation_test.cc b/test/boost/mutation_test.cc
--- a/test/boost/mutation_test.cc
+++ b/test/boost/mutation_test.cc
@@ -2283,7 +2283,7 @@ class clustering_fragment_summary::less_cmp {
}
};

-using collection_element_tri_cmp_type = std::function<int(const std::pair<bytes, cell_summary>&, const std::pair<bytes, cell_summary>&)>;
+using collection_element_tri_cmp_type = std::function<std::strong_ordering(const std::pair<bytes, cell_summary>&, const std::pair<bytes, cell_summary>&)>;

collection_element_tri_cmp_type
collection_element_tri_cmp(const abstract_type& type) {
@@ -2298,13 +2298,7 @@ collection_element_tri_cmp(const abstract_type& type) {
return [] (const std::pair<bytes, cell_summary>& a, const std::pair<bytes, cell_summary>& b) {
auto ai = deserialize_field_index(a.first);
auto bi = deserialize_field_index(b.first);
- if (ai < bi) {
- return -1;
- }
- if (ai == bi) {
- return 0;
- }
- return 1;
+ return ai <=> bi;
};
},
[] (const abstract_type& o) -> collection_element_tri_cmp_type {
diff --git a/types.hh b/types.hh
--- a/types.hh
+++ b/types.hh
@@ -943,11 +943,11 @@ class serialized_tri_compare {
data_type _type;
public:
serialized_tri_compare(data_type type) : _type(type) {}
- int operator()(const bytes_view& v1, const bytes_view& v2) const {
- return _type->compare(v1, v2);
+ std::strong_ordering operator()(const bytes_view& v1, const bytes_view& v2) const {
+ return _type->compare(v1, v2) <=> 0;
}
- int operator()(const managed_bytes_view& v1, const managed_bytes_view& v2) const {
- return _type->compare(v1, v2);
+ std::strong_ordering operator()(const managed_bytes_view& v1, const managed_bytes_view& v2) const {
+ return _type->compare(v1, v2) <=> 0;
}
};

Commit Bot

unread,
Jul 29, 2021, 9:40:07 PMJul 29
to scylla...@googlegroups.com, Avi Kivity
From: Avi Kivity <a...@scylladb.com>
Committer: Avi Kivity <a...@scylladb.com>
Branch: master
Reply all
Reply to author
Forward
0 new messages