diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-10 02:08:57 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-10 02:13:09 -0800 |
commit | 75921593c0f8f33133034bc56dc94d956d2afd67 (patch) | |
tree | f674de5fd73a8ab1dd507c3813e2dcde90327d91 /crawl-ref/source/store.h | |
parent | 5e9e9773f748ab17c8298cd212c77bf5ea1b2051 (diff) | |
download | crawl-ref-75921593c0f8f33133034bc56dc94d956d2afd67.tar.gz crawl-ref-75921593c0f8f33133034bc56dc94d956d2afd67.zip |
CrawlHashTable: reduce RAM overhead
The RAM overhead for an unused CrawlHash table has been reduced from 32
to 4 (on 32 bit systems), with an increased overhead of 4 bytes for ones
which are used. This leads to a 35% RAM reduction for item_def
instances with an unused props field.
Diffstat (limited to 'crawl-ref/source/store.h')
-rw-r--r-- | crawl-ref/source/store.h | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/crawl-ref/source/store.h b/crawl-ref/source/store.h index 1eae58f2b2..e23e6056be 100644 --- a/crawl-ref/source/store.h +++ b/crawl-ref/source/store.h @@ -109,8 +109,7 @@ public: store_flags unset_flags(store_flags flags); store_val_type get_type() const; - CrawlHashTable &new_table(store_flags flags); - CrawlHashTable &new_table(store_val_type type, store_flags flags = 0); + CrawlHashTable &new_table(); CrawlVector &new_vector(store_flags flags, vec_size max_size = VEC_MAX_SIZE); @@ -270,8 +269,7 @@ class CrawlHashTable { public: CrawlHashTable(); - CrawlHashTable(store_flags flags); - CrawlHashTable(store_val_type type, store_flags flags = 0); + CrawlHashTable(const CrawlHashTable& other); ~CrawlHashTable(); @@ -280,22 +278,22 @@ public: typedef hash_map_type::const_iterator const_iterator; protected: - store_val_type type; - store_flags default_flags; - hash_map_type hash_map; + // NOTE: Not using std::auto_ptr because making hash_map an auto_ptr + // causes compile weirdness in externs.h + hash_map_type *hash_map; + + void init_hash_map(); friend class CrawlStoreValue; public: + CrawlHashTable &operator = (const CrawlHashTable &other); + void write(writer &) const; void read(reader &); - store_flags get_default_flags() const; - store_flags set_default_flags(store_flags flags); - store_flags unset_default_flags(store_flags flags); - store_val_type get_type() const; - bool exists(const std::string &key) const; - void assert_validity() const; + bool exists(const std::string &key) const; + void assert_validity() const; // NOTE: If the const versions of get_value() or [] are given a // key which doesn't exist, they will assert. |