1/* 2 * Copyright 2021 Google LLC. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7#include "include/core/SkStringView.h" 8 9#include <algorithm> 10 11namespace skstd { 12 13bool operator==(string_view left, string_view right) { 14 if (left.length() != right.length()) { 15 return false; 16 } 17 return !string_view::traits_type::compare(left.data(), right.data(), left.length()); 18} 19 20bool operator!=(string_view left, string_view right) { 21 return !(left == right); 22} 23 24bool operator<(string_view left, string_view right) { 25 int result = string_view::traits_type::compare(left.data(), right.data(), 26 std::min(left.length(), right.length())); 27 if (!result) { 28 result = left.length() - right.length(); 29 } 30 return result < 0; 31} 32 33bool operator<=(string_view left, string_view right) { 34 return !(left > right); 35} 36 37bool operator>(string_view left, string_view right) { 38 return right < left; 39} 40 41bool operator>=(string_view left, string_view right) { 42 return !(left < right); 43} 44 45} // namespace skstd 46