QString: use first and last more

It's safe here, precondition is earlier

Change-Id: Ib2192fc729cd012d0983843678c546283a655bfd
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Anton Kudryavtsev 2023-09-15 11:12:47 +03:00
parent 34a0dbc3a9
commit 48a44cdf65

View File

@ -263,7 +263,7 @@ bool qt_starts_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity c
if (needleLen > haystackLen)
return false;
return QtPrivate::compareStrings(haystack.left(needleLen), needle, cs) == 0;
return QtPrivate::compareStrings(haystack.first(needleLen), needle, cs) == 0;
}
template <typename Haystack, typename Needle>
@ -278,7 +278,7 @@ bool qt_ends_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs)
if (haystackLen < needleLen)
return false;
return QtPrivate::compareStrings(haystack.right(needleLen), needle, cs) == 0;
return QtPrivate::compareStrings(haystack.last(needleLen), needle, cs) == 0;
}
template <typename T>