Optimize QArrayDataOps::compare for primitive types

Change-Id: If726e3ee8a3635dcec2a316f1a829392de298634
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
bb10
Lars Knoll 2019-11-25 17:53:55 +01:00
parent f247e94b51
commit db89349bdb
1 changed files with 5 additions and 0 deletions

View File

@ -199,6 +199,11 @@ struct QPodArrayOps
bool compare(const T *begin1, const T *begin2, size_t n) const
{
// only use memcmp for fundamental types or pointers.
// Other types could have padding in the data structure or custom comparison
// operators that would break the comparison using memcmp
if (QArrayDataPointer<T>::pass_parameter_by_value)
return ::memcmp(begin1, begin2, n * sizeof(T)) == 0;
const T *end1 = begin1 + n;
while (begin1 != end1) {
if (*begin1 == *begin2)