aboutsummaryrefslogtreecommitdiff
path: root/common/hashmap.h
diff options
context:
space:
mode:
authorAlyssa Milburn2011-07-07 09:24:10 +0200
committerAlyssa Milburn2011-07-07 09:24:10 +0200
commit66e81d633f987310f12038147ae01b8ce4f640f7 (patch)
tree6035a7124789c3e6cdff5f603e9933529b7efdc7 /common/hashmap.h
parentaffaa1f4d6cf5f27f654029133b1aec7b9eca4b5 (diff)
parent72da8ef5adf82d8a65da299207f30af5058ca8a9 (diff)
downloadscummvm-rg350-66e81d633f987310f12038147ae01b8ce4f640f7.tar.gz
scummvm-rg350-66e81d633f987310f12038147ae01b8ce4f640f7.tar.bz2
scummvm-rg350-66e81d633f987310f12038147ae01b8ce4f640f7.zip
Merge remote-tracking branch 'origin/master' into soltys_wip2
Diffstat (limited to 'common/hashmap.h')
-rw-r--r--common/hashmap.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/common/hashmap.h b/common/hashmap.h
index f2a4d843b8..347ac1fd25 100644
--- a/common/hashmap.h
+++ b/common/hashmap.h
@@ -106,8 +106,9 @@ private:
HASHMAP_MEMORYPOOL_SIZE = HASHMAP_MIN_CAPACITY * HASHMAP_LOADFACTOR_NUMERATOR / HASHMAP_LOADFACTOR_DENOMINATOR
};
-
+#ifdef USE_HASHMAP_MEMORY_POOL
ObjectPool<Node, HASHMAP_MEMORYPOOL_SIZE> _nodePool;
+#endif
Node **_storage; ///< hashtable of size arrsize.
uint _mask; ///< Capacity of the HashMap minus one; must be a power of two of minus one
@@ -128,12 +129,20 @@ private:
#endif
Node *allocNode(const Key &key) {
+#ifdef USE_HASHMAP_MEMORY_POOL
return new (_nodePool) Node(key);
+#else
+ return new Node(key);
+#endif
}
void freeNode(Node *node) {
if (node && node != HASHMAP_DUMMY_NODE)
+#ifdef USE_HASHMAP_MEMORY_POOL
_nodePool.deleteChunk(node);
+#else
+ delete node;
+#endif
}
void assign(const HM_t &map);