don't calculate hash when the map is empty and we are not inserting
the alternative would be splitting the function into two separate overloads. that might result in better branch prediction, but will create a bit more code. Change-Id: Ia2c685bbb34a9681c71f2249d073dd960368209a Reviewed-on: http://codereview.qt-project.org/5332 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
bbd02d7086
commit
f6e0aa3a0f
@ -879,8 +879,13 @@ Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(cons
|
||||
uint *ahp) const
|
||||
{
|
||||
Node **node;
|
||||
uint h = qHash(akey);
|
||||
uint h;
|
||||
|
||||
if (d->numBuckets || ahp) {
|
||||
h = qHash(akey);
|
||||
if (ahp)
|
||||
*ahp = h;
|
||||
}
|
||||
if (d->numBuckets) {
|
||||
node = reinterpret_cast<Node **>(&d->buckets[h % d->numBuckets]);
|
||||
Q_ASSERT(*node == e || (*node)->next);
|
||||
@ -889,8 +894,6 @@ Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(cons
|
||||
} else {
|
||||
node = const_cast<Node **>(reinterpret_cast<const Node * const *>(&e));
|
||||
}
|
||||
if (ahp)
|
||||
*ahp = h;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user