QItemSelectionRange: speedup intersects() in negative case
QItemSelectionRange::intersects() needs to check if the parent of both QItemSelectionRanges is the same. This is a very expensive operation which should be done last. Same goes for isValid() which itself calls parent() for two indexes. This rearrangement speeds up some worst-case usecases by at least 30% as shown in the bug report. Task-number: QTBUG-60940 Change-Id: If6111a73cb8b97a8a0d0640527b34448d21f3143 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>bb10
parent
f0e9d268c2
commit
8a1f0d1f6c
|
|
@ -218,13 +218,15 @@ QT_BEGIN_NAMESPACE
|
|||
*/
|
||||
bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const
|
||||
{
|
||||
return (isValid() && other.isValid()
|
||||
&& parent() == other.parent()
|
||||
&& model() == other.model()
|
||||
// isValid() and parent() last since they are more expensive
|
||||
return (model() == other.model()
|
||||
&& ((top() <= other.top() && bottom() >= other.top())
|
||||
|| (top() >= other.top() && top() <= other.bottom()))
|
||||
&& ((left() <= other.left() && right() >= other.left())
|
||||
|| (left() >= other.left() && left() <= other.right())));
|
||||
|| (left() >= other.left() && left() <= other.right()))
|
||||
&& parent() == other.parent()
|
||||
&& isValid() && other.isValid()
|
||||
);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue