[Scummvm-cvs-logs] SF.net SVN: scummvm:[54003] scummvm/trunk/common

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Nov 1 17:00:53 CET 2010


Revision: 54003
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54003&view=rev
Author:   fingolfin
Date:     2010-11-01 16:00:53 +0000 (Mon, 01 Nov 2010)

Log Message:
-----------
COMMON: Change some (f)printf to debug calls; clenaup hashmap.h

Modified Paths:
--------------
    scummvm/trunk/common/config-manager.cpp
    scummvm/trunk/common/hashmap.cpp
    scummvm/trunk/common/hashmap.h
    scummvm/trunk/common/memorypool.cpp

Modified: scummvm/trunk/common/config-manager.cpp
===================================================================
--- scummvm/trunk/common/config-manager.cpp	2010-11-01 16:00:35 UTC (rev 54002)
+++ scummvm/trunk/common/config-manager.cpp	2010-11-01 16:00:53 UTC (rev 54003)
@@ -69,7 +69,7 @@
 
 	} 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 @@
 	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);
 	}
 }

Modified: scummvm/trunk/common/hashmap.cpp
===================================================================
--- scummvm/trunk/common/hashmap.cpp	2010-11-01 16:00:35 UTC (rev 54002)
+++ scummvm/trunk/common/hashmap.cpp	2010-11-01 16:00:53 UTC (rev 54003)
@@ -89,7 +89,7 @@
 	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 @@
 		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,

Modified: scummvm/trunk/common/hashmap.h
===================================================================
--- scummvm/trunk/common/hashmap.h	2010-11-01 16:00:35 UTC (rev 54002)
+++ scummvm/trunk/common/hashmap.h	2010-11-01 16:00:53 UTC (rev 54003)
@@ -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,12 +69,7 @@
 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.
  * For each used Key type, we need an "uint hashit(Key,uint)" function
@@ -460,7 +477,7 @@
 
 #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 @@
 
 #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

Modified: scummvm/trunk/common/memorypool.cpp
===================================================================
--- scummvm/trunk/common/memorypool.cpp	2010-11-01 16:00:35 UTC (rev 54002)
+++ scummvm/trunk/common/memorypool.cpp	2010-11-01 16:00:53 UTC (rev 54003)
@@ -161,7 +161,7 @@
 		}
 	}
 
-//	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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list