QHash: constify some QHashNode members

They're read-only member variables (key, hash value of the key)
set only in the ctors, or a "comparison" member function.
All of them can be constified.

Change-Id: Ifd9242577213f38439a4f998b678f5b05413ad21
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: João Abecasis <joao@abecasis.name>
This commit is contained in:
Giuseppe D'Angelo 2012-11-10 16:32:49 +00:00 committed by The Qt Project
parent b8be2e67ea
commit 45fecb2472

View File

@ -203,21 +203,21 @@ template <class Key, class T>
struct QHashNode struct QHashNode
{ {
QHashNode *next; QHashNode *next;
uint h; const uint h;
Key key; const Key key;
T value; T value;
inline QHashNode(const Key &key0, const T &value0, uint hash, QHashNode *n) inline QHashNode(const Key &key0, const T &value0, uint hash, QHashNode *n)
: next(n), h(hash), key(key0), value(value0) {} : next(n), h(hash), key(key0), value(value0) {}
inline bool same_key(uint h0, const Key &key0) { return h0 == h && key0 == key; } inline bool same_key(uint h0, const Key &key0) const { return h0 == h && key0 == key; }
}; };
template <class Key, class T> template <class Key, class T>
struct QHashDummyNode struct QHashDummyNode
{ {
QHashNode<Key, T> *next; QHashNode<Key, T> *next;
uint h; const uint h;
Key key; const Key key;
inline QHashDummyNode(const Key &key0, uint hash, QHashNode<Key, T> *n) : next(n), h(hash), key(key0) {} inline QHashDummyNode(const Key &key0, uint hash, QHashNode<Key, T> *n) : next(n), h(hash), key(key0) {}
}; };
@ -253,7 +253,7 @@ struct QHashDummyNode
\ \
inline QHashNode(key_type /* key0 */) {} \ inline QHashNode(key_type /* key0 */) {} \
inline QHashNode(key_type /* key0 */, const T &value0) : value(value0) {} \ inline QHashNode(key_type /* key0 */, const T &value0) : value(value0) {} \
inline bool same_key(uint h0, key_type) { return h0 == h; } \ inline bool same_key(uint h0, key_type) const { return h0 == h; } \
} }
#if defined(Q_BYTE_ORDER) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN #if defined(Q_BYTE_ORDER) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN