Remove unnecessary copying in QSet::subtract()
Task-number: QTBUG-42810 Change-Id: I5d4793a12b078e34bea034b4500e270d42609de0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
35781b3588
commit
33693473d4
|
|
@ -340,13 +340,14 @@ Q_INLINE_TEMPLATE bool QSet<T>::intersects(const QSet<T> &other) const
|
|||
template <class T>
|
||||
Q_INLINE_TEMPLATE QSet<T> &QSet<T>::subtract(const QSet<T> &other)
|
||||
{
|
||||
QSet<T> copy1(*this);
|
||||
QSet<T> copy2(other);
|
||||
typename QSet<T>::const_iterator i = copy1.constEnd();
|
||||
while (i != copy1.constBegin()) {
|
||||
--i;
|
||||
if (copy2.contains(*i))
|
||||
if (&other == this) {
|
||||
clear();
|
||||
} else {
|
||||
auto i = other.constEnd();
|
||||
while (i != other.constBegin()) {
|
||||
--i;
|
||||
remove(*i);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue