types: move compare_unsigned() to bytes.hh
compare_unsigned() is a general utility function that compares two bytes_view byte-by-byte. There is no need to include whole type.hh in order to make it available.
This commit is contained in:
8
bytes.hh
8
bytes.hh
@@ -78,3 +78,11 @@ struct appending_hash<bytes_view> {
|
||||
h.update(reinterpret_cast<const char*>(v.begin()), v.size() * sizeof(bytes_view::value_type));
|
||||
}
|
||||
};
|
||||
|
||||
inline int32_t compare_unsigned(bytes_view v1, bytes_view v2) {
|
||||
auto n = memcmp(v1.begin(), v2.begin(), std::min(v1.size(), v2.size()));
|
||||
if (n) {
|
||||
return n;
|
||||
}
|
||||
return (int32_t) (v1.size() - v2.size());
|
||||
}
|
||||
|
||||
8
types.hh
8
types.hh
@@ -223,14 +223,6 @@ public:
|
||||
virtual const char* what() const noexcept override { return _why.c_str(); }
|
||||
};
|
||||
|
||||
inline int32_t compare_unsigned(bytes_view v1, bytes_view v2) {
|
||||
auto n = memcmp(v1.begin(), v2.begin(), std::min(v1.size(), v2.size()));
|
||||
if (n) {
|
||||
return n;
|
||||
}
|
||||
return (int32_t) (v1.size() - v2.size());
|
||||
}
|
||||
|
||||
struct empty_t {};
|
||||
|
||||
class empty_value_exception : public std::exception {
|
||||
|
||||
Reference in New Issue
Block a user