Commit 937da63b authored by Max Kellermann's avatar Max Kellermann Committed by Max Kellermann

util/StringView: add {Starts,Ends}With(char)

parent 1f312b2e
......@@ -155,6 +155,16 @@ struct BasicStringView : ConstBuffer<T> {
}
gcc_pure
bool StartsWith(value_type ch) const noexcept {
return !empty() && front() == ch;
}
gcc_pure
bool EndsWith(value_type ch) const noexcept {
return !empty() && back() == ch;
}
gcc_pure
int Compare(BasicStringView<T> other) const noexcept {
if (size < other.size) {
int result = StringCompare(data, other.data, size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment