summaryrefslogtreecommitdiff
path: root/yapf/hashtable.hpp
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2006-11-18 19:20:47 +0000
committerKUDr <kudr@openttd.org>2006-11-18 19:20:47 +0000
commit9b81f084af2a19da3487fa747bc40f2c4b876845 (patch)
tree0dcbe68a8fa0166ef30d7a7f8870a502837bfa23 /yapf/hashtable.hpp
parent3f64e50fc9a8f336fae1e59adabf604d8778cd4e (diff)
downloadopenttd-9b81f084af2a19da3487fa747bc40f2c4b876845.tar.xz
(svn r7210) -CodeChange: [YAPF] the global cache object is now not destroyed/recreated whenever the cache is invalidated. It now supports Flush() method that is used instead. It should also fix mem-leak warning produced by valgrind (Tron)
Diffstat (limited to 'yapf/hashtable.hpp')
-rw-r--r--yapf/hashtable.hpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/yapf/hashtable.hpp b/yapf/hashtable.hpp
index 71c4eac74..c6b52e50a 100644
--- a/yapf/hashtable.hpp
+++ b/yapf/hashtable.hpp
@@ -12,6 +12,9 @@ struct CHashTableSlotT
CHashTableSlotT() : m_pFirst(NULL) {}
+ /** hash table slot helper - clears the slot by simple forgetting its items */
+ FORCEINLINE void Clear() {m_pFirst = NULL;}
+
/** hash table slot helper - linear search for item with given key through the given blob - const version */
FORCEINLINE const Titem_* Find(const Key& key) const
{
@@ -162,6 +165,9 @@ public:
/** item count */
FORCEINLINE int Count() const {return m_num_items;}
+ /** simple clear - forget all items - used by CSegmentCostCacheT.Flush() */
+ FORCEINLINE void Clear() const {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();}
+
/** const item search */
const Titem_* Find(const Tkey& key) const
{