diff options
author | Max Horn | 2010-11-01 16:00:53 +0000 |
---|---|---|
committer | Max Horn | 2010-11-01 16:00:53 +0000 |
commit | 7a853650047064fb15720bb58ce7c5eec28ef606 (patch) | |
tree | e6818d7eae0e28a63bea716fe53a59b549dd66e1 | |
parent | 6fa8772baef4e76a1cb4b92c14f2479def8210b5 (diff) | |
download | scummvm-rg350-7a853650047064fb15720bb58ce7c5eec28ef606.tar.gz scummvm-rg350-7a853650047064fb15720bb58ce7c5eec28ef606.tar.bz2 scummvm-rg350-7a853650047064fb15720bb58ce7c5eec28ef606.zip |
COMMON: Change some (f)printf to debug calls; clenaup hashmap.h
svn-id: r54003
-rw-r--r-- | common/config-manager.cpp | 6 | ||||
-rw-r--r-- | common/hashmap.cpp | 4 | ||||
-rw-r--r-- | common/hashmap.h | 33 | ||||
-rw-r--r-- | common/memorypool.cpp | 2 |
4 files changed, 31 insertions, 14 deletions
diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 554a99ea95..8c9a03cb94 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -69,7 +69,7 @@ void ConfigManager::loadDefaultConfigFile() { } else { // No config file -> create new one! - printf("Default configuration file missing, creating a new one\n"); + debug("Default configuration file missing, creating a new one"); flushToDisk(); } @@ -81,9 +81,9 @@ void ConfigManager::loadConfigFile(const String &filename) { FSNode node(filename); File cfg_file; if (!cfg_file.open(node)) { - printf("Creating configuration file: %s\n", filename.c_str()); + debug("Creating configuration file: %s\n", filename.c_str()); } else { - printf("Using configuration file: %s\n", _filename.c_str()); + debug("Using configuration file: %s\n", _filename.c_str()); loadFromStream(cfg_file); } } diff --git a/common/hashmap.cpp b/common/hashmap.cpp index d8b84f61a5..5fe18f33ee 100644 --- a/common/hashmap.cpp +++ b/common/hashmap.cpp @@ -89,7 +89,7 @@ void updateHashCollisionStats(int collisions, int dummyHits, int lookups, int ar g_max_capacity = MAX(g_max_capacity, arrsize); g_max_size = MAX(g_max_size, nele); - fprintf(stdout, "%d hashmaps: colls %.1f; dummies hit %.1f, lookups %.1f; ratio %.3f%%; size %f (max: %d); capacity %f (max: %d)\n", + debug("%d hashmaps: colls %.1f; dummies hit %.1f, lookups %.1f; ratio %.3f%%; size %f (max: %d); capacity %f (max: %d)", g_totalHashmaps, g_collisions / g_totalHashmaps, g_dummyHits / g_totalHashmaps, @@ -97,7 +97,7 @@ void updateHashCollisionStats(int collisions, int dummyHits, int lookups, int ar 100 * g_collPerLook / g_totalHashmaps, g_size / g_totalHashmaps, g_max_size, g_capacity / g_totalHashmaps, g_max_capacity); - fprintf(stdout, " %d less than %d; %d less than %d; %d less than %d; %d less than %d\n", + debug(" %d less than %d; %d less than %d; %d less than %d; %d less than %d", g_stats[0], 2*8/3, g_stats[1],2*16/3, g_stats[2],2*32/3, diff --git a/common/hashmap.h b/common/hashmap.h index 45192256a9..2607828c45 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -29,15 +29,37 @@ #ifndef COMMON_HASHMAP_H #define COMMON_HASHMAP_H +/** + * @def DEBUG_HASH_COLLISIONS + * Enable the following #define if you want to check how many collisions the + * code produces (many collisions indicate either a bad hash function, or a + * hash table that is too small). + */ +#define DEBUG_HASH_COLLISIONS + +/** + * @def USE_HASHMAP_MEMORY_POOL + * Enable the following define to let HashMaps use a memory pool for the + nodes they contain. * This increases memory usage, but also can improve + speed quite a bit. + */ +#define USE_HASHMAP_MEMORY_POOL + + #include "common/func.h" #include "common/str.h" #include "common/util.h" -#define USE_HASHMAP_MEMORY_POOL +#ifdef DEBUG_HASH_COLLISIONS +#include "common/debug.h" +#endif + #ifdef USE_HASHMAP_MEMORY_POOL #include "common/memorypool.h" #endif + + namespace Common { // The sgi IRIX MIPSpro Compiler has difficulties with nested templates. @@ -47,11 +69,6 @@ namespace Common { template<class T> class IteratorImpl; #endif -// Enable the following #define if you want to check how many collisions the -// code produces (many collisions indicate either a bad hash function, or a -// hash table that is too small). -//#define DEBUG_HASH_COLLISIONS - /** * HashMap<Key,Val> maps objects of type Key to objects of type Val. @@ -460,7 +477,7 @@ int HashMap<Key, Val, HashFunc, EqualFunc>::lookup(const Key &key) const { #ifdef DEBUG_HASH_COLLISIONS _lookups++; - fprintf(stderr, "collisions %d, dummies hit %d, lookups %d, ratio %f in HashMap %p; size %d num elements %d\n", + debug("collisions %d, dummies hit %d, lookups %d, ratio %f in HashMap %p; size %d num elements %d", _collisions, _dummyHits, _lookups, ((double) _collisions / (double)_lookups), (const void *)this, _mask+1, _size); #endif @@ -498,7 +515,7 @@ int HashMap<Key, Val, HashFunc, EqualFunc>::lookupAndCreateIfMissing(const Key & #ifdef DEBUG_HASH_COLLISIONS _lookups++; - fprintf(stderr, "collisions %d, dummies hit %d, lookups %d, ratio %f in HashMap %p; size %d num elements %d\n", + debug("collisions %d, dummies hit %d, lookups %d, ratio %f in HashMap %p; size %d num elements %d", _collisions, _dummyHits, _lookups, ((double) _collisions / (double)_lookups), (const void *)this, _mask+1, _size); #endif diff --git a/common/memorypool.cpp b/common/memorypool.cpp index c677c45ff4..c4dbb5fbbd 100644 --- a/common/memorypool.cpp +++ b/common/memorypool.cpp @@ -161,7 +161,7 @@ void MemoryPool::freeUnusedPages() { } } -// printf("freed %d pages out of %d\n", (int)freedPagesCount, (int)_pages.size()); +// debug("freed %d pages out of %d", (int)freedPagesCount, (int)_pages.size()); // Remove all now unused pages size_t newSize = 0; |