diff --git a/src/support/istring.h b/src/support/istring.h index a567eb82f12..f567cb4d97a 100644 --- a/src/support/istring.h +++ b/src/support/istring.h @@ -113,8 +113,7 @@ struct IString { bool equals(std::string_view other) const { return str.view() == other; } bool startsWith(std::string_view prefix) const { - // TODO: Use C++20 `starts_with`. - return view().substr(0, prefix.size()) == prefix; + return view().starts_with(prefix); } bool startsWith(IString other) const { return startsWith(other.view()); } @@ -124,11 +123,7 @@ struct IString { } bool endsWith(std::string_view suffix) const { - // TODO: Use C++20 `ends_with`. - if (suffix.size() > str.size()) { - return false; - } - return view().substr(str.size() - suffix.size()) == suffix; + return view().ends_with(suffix); } bool endsWith(IString other) const { return endsWith(other.view()); }