HomeAleph Objects Inc

QHash: optimize equality operator

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

Description

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>

Details

Event Timeline

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