aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/ftw/qhashedstring_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-02-21 10:41:54 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2018-02-26 07:13:18 +0000
commit499ec43937e926e4f2fa57a9baa455fcb3862262 (patch)
tree206c90d47387f8322b68f5e3db613189397e1af3 /src/qml/qml/ftw/qhashedstring_p.h
parent53d1e9ed21d25e65a2f13606af479838f5f21fe7 (diff)
use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/ftw/qhashedstring_p.h')
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
index 956805d696..bd2c9fbdb7 100644
--- a/src/qml/qml/ftw/qhashedstring_p.h
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -179,7 +179,7 @@ class Q_AUTOTEST_EXPORT QStringHashNode
{
public:
QStringHashNode()
- : length(0), hash(0), symbolId(0), ckey(0)
+ : length(0), hash(0), symbolId(0), ckey(nullptr)
{
}
@@ -277,7 +277,7 @@ class Q_AUTOTEST_EXPORT QStringHashData
{
public:
QStringHashData()
- : buckets(0), numBuckets(0), size(0), numBits(0)
+ : buckets(nullptr), numBuckets(0), size(0), numBits(0)
#ifdef QSTRINGHASH_LINK_DEBUG
, linkCount(0)
#endif
@@ -292,7 +292,7 @@ public:
#endif
struct IteratorData {
- IteratorData() : n(0), p(0) {}
+ IteratorData() : n(nullptr), p(nullptr) {}
QStringHashNode *n;
void *p;
};
@@ -362,14 +362,14 @@ public:
T value;
};
struct NewedNode : public Node {
- NewedNode(const QHashedString &key, const T &value) : Node(key, value), nextNewed(0) {}
- NewedNode(const QHashedCStringRef &key, const T &value) : Node(key, value), nextNewed(0) {}
- NewedNode(const Node &o) : Node(o), nextNewed(0) {}
+ NewedNode(const QHashedString &key, const T &value) : Node(key, value), nextNewed(nullptr) {}
+ NewedNode(const QHashedCStringRef &key, const T &value) : Node(key, value), nextNewed(nullptr) {}
+ NewedNode(const Node &o) : Node(o), nextNewed(nullptr) {}
NewedNode *nextNewed;
};
struct ReservedNodePool
{
- ReservedNodePool() : count(0), used(0), nodes(0) {}
+ ReservedNodePool() : count(0), used(0), nodes(nullptr) {}
~ReservedNodePool() { delete [] nodes; }
int count;
int used;
@@ -475,13 +475,13 @@ public:
template<class T>
QStringHash<T>::QStringHash()
-: newedNodes(0), nodePool(0), link(0)
+: newedNodes(nullptr), nodePool(nullptr), link(nullptr)
{
}
template<class T>
QStringHash<T>::QStringHash(const QStringHash<T> &other)
-: newedNodes(0), nodePool(0), link(0)
+: newedNodes(nullptr), nodePool(nullptr), link(nullptr)
{
data.numBits = other.data.numBits;
data.size = other.data.size;
@@ -579,14 +579,14 @@ void QStringHash<T>::clear()
if (nodePool) delete nodePool;
delete [] data.buckets;
- data.buckets = 0;
+ data.buckets = nullptr;
data.numBuckets = 0;
data.numBits = 0;
data.size = 0;
- newedNodes = 0;
- nodePool = 0;
- link = 0;
+ newedNodes = nullptr;
+ nodePool = nullptr;
+ link = nullptr;
}
template<class T>
@@ -716,16 +716,16 @@ QStringHash<T>::iterateNext(const QStringHashData::IteratorData &d)
node < (This->nodePool->nodes + This->nodePool->used)) {
node--;
if (node < This->nodePool->nodes)
- node = 0;
+ node = nullptr;
} else {
NewedNode *nn = (NewedNode *)node;
node = nn->nextNewed;
- if (node == 0 && This->nodePool && This->nodePool->used)
+ if (node == nullptr && This->nodePool && This->nodePool->used)
node = This->nodePool->nodes + This->nodePool->used - 1;
}
- if (node == 0 && This->link)
+ if (node == nullptr && This->link)
return This->link->iterateFirst();
QStringHashData::IteratorData rv;
@@ -737,13 +737,13 @@ QStringHash<T>::iterateNext(const QStringHashData::IteratorData &d)
template<class T>
QStringHashData::IteratorData QStringHash<T>::iterateFirst() const
{
- Node *n = 0;
+ Node *n = nullptr;
if (newedNodes)
n = newedNodes;
else if (nodePool && nodePool->used)
n = nodePool->nodes + nodePool->used - 1;
- if (n == 0 && link)
+ if (n == nullptr && link)
return link->iterateFirst();
QStringHashData::IteratorData rv;
@@ -822,7 +822,7 @@ void QStringHash<T>::insert(const K &key, const T &value)
{
// If this is a linked hash, we can't rely on owning the node, so we always
// create a new one.
- Node *n = link?0:findNode(key);
+ Node *n = link?nullptr:findNode(key);
if (n) n->value = value;
else createNode(key, value);
}
@@ -837,7 +837,7 @@ template<class T>
template<class K>
typename QStringHash<T>::Node *QStringHash<T>::findNode(const K &key) const
{
- QStringHashNode *node = data.numBuckets?data.buckets[hashOf(key) % data.numBuckets]:0;
+ QStringHashNode *node = data.numBuckets?data.buckets[hashOf(key) % data.numBuckets]:nullptr;
typename HashedForm<K>::Type hashedKey(hashedString(key));
while (node && !node->equals(hashedKey))
@@ -851,7 +851,7 @@ template<class K>
T *QStringHash<T>::value(const K &key) const
{
Node *n = findNode(key);
- return n?&n->value:0;
+ return n?&n->value:nullptr;
}
template<class T>
@@ -865,14 +865,14 @@ template<class T>
T *QStringHash<T>::value(const QV4::String *string) const
{
Node *n = findNode(string);
- return n?&n->value:0;
+ return n?&n->value:nullptr;
}
template<class T>
template<class K>
bool QStringHash<T>::contains(const K &key) const
{
- return 0 != value(key);
+ return nullptr != value(key);
}
template<class T>
@@ -1089,7 +1089,7 @@ quint32 QHashedString::existingHash() const
}
QHashedStringRef::QHashedStringRef()
-: m_data(0), m_length(0), m_hash(0)
+: m_data(nullptr), m_length(0), m_hash(0)
{
}
@@ -1236,7 +1236,7 @@ quint32 QHashedStringRef::hash() const
}
QHashedCStringRef::QHashedCStringRef()
-: m_data(0), m_length(0), m_hash(0)
+: m_data(nullptr), m_length(0), m_hash(0)
{
}