From 9512d97c90cb5f989100b3ce7c258ea5fc2f7829 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 9 Nov 2016 14:36:08 +0100 Subject: 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 --- src/corelib/tools/qhash.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index d58c3c5733..66b5e75a1a 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -744,7 +744,7 @@ Q_INLINE_TEMPLATE T &QHash::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::iterator QHash::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::iterator, typename QHash::iterator> QHash< template QPair::const_iterator, typename QHash::const_iterator> QHash::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) { -- cgit v1.2.3