util/StringView: add method Compare()
This commit is contained in:
@@ -121,6 +121,23 @@ struct BasicStringView : ConstBuffer<T> {
|
|||||||
needle.data, needle.size);
|
needle.data, needle.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
int Compare(BasicStringView<T> other) const noexcept {
|
||||||
|
if (size < other.size) {
|
||||||
|
int result = StringCompare(data, other.data, size);
|
||||||
|
if (result == 0)
|
||||||
|
result = -1;
|
||||||
|
return result;
|
||||||
|
} else if (size > other.size) {
|
||||||
|
int result = StringCompare(data, other.data,
|
||||||
|
other.size);
|
||||||
|
if (result == 0)
|
||||||
|
result = 1;
|
||||||
|
return result;
|
||||||
|
} else
|
||||||
|
return StringCompare(data, other.data, size);
|
||||||
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool Equals(BasicStringView<T> other) const noexcept {
|
bool Equals(BasicStringView<T> other) const noexcept {
|
||||||
return this->size == other.size &&
|
return this->size == other.size &&
|
||||||
|
Reference in New Issue
Block a user