HomeAleph Objects Inc

QHash: optimize equality operator

Authored by Marc Mutz <marc.mutz@kdab.com> on Jul 10 2019, 11:40 AM.


QHash: optimize equality operator

  • First compare the d-pointer before dipping into *d
  • Keep a running count as we calculate thisEqualRange, as std::distance() on QHash::iterator is very expensive.
  • Skip the pointless first comparison of the unadvanced iterator's key() with itself (found by Mårten Nordheim)

Also rename (it, thisEqualRangeEnd) → (thisEqualRangeStart, it),
to keep advancing it, which is more natural than advancing
an end and later resetting it = end.

Change-Id: I2c27c071b9ee23425a763328402dad9efee4cbd0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>


Event Timeline

Marc Mutz <marc.mutz@kdab.com> committed rQTB0fec7417ca30: QHash: optimize equality operator (authored by Marc Mutz <marc.mutz@kdab.com>).Jul 12 2019, 8:43 AM