Remove a few unnecessary recalculations of hash
When we already have the hash-value we can give it to findNode to avoid recalculating it, and if don't need it later, we don't need to request it. Removes around 1% of qHash calls when running QtCreator. Change-Id: I0e5e61e26a407f4ac7e029a3ac13ddd553e4994b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
f7a7b9796e
commit
9512d97c90
|
|
@ -744,7 +744,7 @@ Q_INLINE_TEMPLATE T &QHash<Key, T>::operator[](const Key &akey)
|
|||
Node **node = findNode(akey, &h);
|
||||
if (*node == e) {
|
||||
if (d->willGrow())
|
||||
node = findNode(akey, &h);
|
||||
node = findNode(akey, h);
|
||||
return createNode(h, akey, T(), node)->value;
|
||||
}
|
||||
return (*node)->value;
|
||||
|
|
@ -760,7 +760,7 @@ Q_INLINE_TEMPLATE typename QHash<Key, T>::iterator QHash<Key, T>::insert(const K
|
|||
Node **node = findNode(akey, &h);
|
||||
if (*node == e) {
|
||||
if (d->willGrow())
|
||||
node = findNode(akey, &h);
|
||||
node = findNode(akey, h);
|
||||
return iterator(createNode(h, akey, avalue, node));
|
||||
}
|
||||
|
||||
|
|
@ -961,8 +961,7 @@ QPair<typename QHash<Key, T>::iterator, typename QHash<Key, T>::iterator> QHash<
|
|||
template <class Key, class T>
|
||||
QPair<typename QHash<Key, T>::const_iterator, typename QHash<Key, T>::const_iterator> QHash<Key, T>::equal_range(const Key &akey) const Q_DECL_NOTHROW
|
||||
{
|
||||
uint h;
|
||||
Node *node = *findNode(akey, &h);
|
||||
Node *node = *findNode(akey);
|
||||
const_iterator firstIt = const_iterator(node);
|
||||
|
||||
if (node != e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue