QVarLengthArray: Do not require operator!= for element comparison

The documentation claims that operator== is needed, not operator!=.
While at it, we can also replace the loop with std::equal, which
might even allow STL implementations to choose a hand-optimized
version of the algorithm for C++ builtin types ...

Change-Id: I988b326d6af3b767526952e303468e18ff6594f9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Kai Koehne 2015-03-18 09:27:15 +01:00
parent d3659bf88b
commit be3d4ebcbf
1 changed files with 4 additions and 5 deletions

View File

@ -468,11 +468,10 @@ bool operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T,
{
if (l.size() != r.size())
return false;
for (int i = 0; i < l.size(); i++) {
if (l.at(i) != r.at(i))
return false;
}
return true;
const T *rb = r.begin();
const T *b = l.begin();
const T *e = l.end();
return std::equal(b, e, rb);
}
template <typename T, int Prealloc1, int Prealloc2>