Removed unneeded copies

This commit is contained in:
Krystian Stasiowski
2019-10-27 16:26:49 -04:00
parent b8695d8644
commit 9156aa8ec8
2 changed files with 13 additions and 22 deletions

View File

@ -667,12 +667,10 @@ find(
size_type n) const ->
size_type
{
if (pos > n_)
if (pos > n_ || n > n_ - pos)
return npos;
if (!n)
return pos;
if (n > n_ - pos)
return npos;
const auto res = std::search(&s_[pos], &s_[n_], s, &s[n], Traits::eq);
return res == end() ? npos : std::distance(s_, res);
}