summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2011-04-19 18:20:34 +0000
committersmatz <smatz@openttd.org>2011-04-19 18:20:34 +0000
commit9eafc6c28fd806fe81214e8e96de17a26d824698 (patch)
tree17d36851a19b47be0578fe8103fdbbac47b57632 /src/misc
parent0c55cbfa73ca1ebfa7e22dd0778d87249ae5b31b (diff)
downloadopenttd-9eafc6c28fd806fe81214e8e96de17a26d824698.tar.xz
(svn r22351) -Revert (r17101): and reinstall r16546. Hash tables are much smaller now, so it shouldn't cause crash anymore
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/hashtable.hpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/misc/hashtable.hpp b/src/misc/hashtable.hpp
index 3289d3bbf..c59187f4e 100644
--- a/src/misc/hashtable.hpp
+++ b/src/misc/hashtable.hpp
@@ -145,20 +145,15 @@ protected:
*/
typedef CHashTableSlotT<Titem_> Slot;
- Slot *m_slots; // here we store our data (array of blobs)
- int m_num_items; // item counter
+ Slot m_slots[Tcapacity]; // here we store our data (array of blobs)
+ int m_num_items; // item counter
public:
/* default constructor */
- FORCEINLINE CHashTableT()
+ FORCEINLINE CHashTableT() : m_num_items(0)
{
- /* construct all slots */
- m_slots = new Slot[Tcapacity];
- m_num_items = 0;
}
- ~CHashTableT() {delete [] m_slots; m_num_items = 0; m_slots = NULL;}
-
protected:
/** static helper - return hash for the given key modulo number of slots */
FORCEINLINE static int CalcHash(const Tkey& key)
@@ -180,7 +175,7 @@ public:
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();}
+ FORCEINLINE void Clear() {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();}
/** const item search */
const Titem_ *Find(const Tkey& key) const