Utils: Fix SmallString::contains

Both strings are not null terminated.

Change-Id: Ib9fb88925ef6ba261ae3c1ef69f0450935d31cc1
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Marco Bubke
2023-07-20 17:14:12 +02:00
committed by Tim Jenssen
parent 8cde647972
commit 655ec9d948

View File

@@ -343,12 +343,10 @@ public:
return BasicSmallString(utf8ByteArray.constData(), uint(utf8ByteArray.size())); return BasicSmallString(utf8ByteArray.constData(), uint(utf8ByteArray.size()));
} }
// precondition: has to be null terminated
bool contains(SmallStringView subStringToSearch) const bool contains(SmallStringView subStringToSearch) const
{ {
const char *found = std::strstr(data(), subStringToSearch.data()); return SmallStringView{*this}.find(subStringToSearch)
!= SmallStringView::npos;
return found != nullptr;
} }
bool contains(char characterToSearch) const bool contains(char characterToSearch) const