Skip to content

Commit

Permalink
Use std::equal instead of substr.
Browse files Browse the repository at this point in the history
  • Loading branch information
ttsugriy authored and anonrig committed Aug 29, 2023
1 parent 5695ae1 commit 6313d3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/to_ascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ bool constexpr begins_with(std::u32string_view view,
if (view.size() < prefix.size()) {
return false;
}
return view.substr(0, prefix.size()) == prefix;
return std::equal(prefix.begin(), prefix.end(), view.begin());
}

bool constexpr begins_with(std::string_view view, std::string_view prefix) {
if (view.size() < prefix.size()) {
return false;
}
return view.substr(0, prefix.size()) == prefix;
return std::equal(prefix.begin(), prefix.end(), view.begin());
}

bool constexpr is_ascii(std::u32string_view view) {
Expand Down

0 comments on commit 6313d3a

Please sign in to comment.