summaryrefslogtreecommitdiffstats
path: root/src/objcache.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2011-12-10 20:30:14 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2011-12-10 20:30:14 (GMT)
commitb625258a2f46f61e85bf473dfa64b719755c3b71 (patch)
treebb2f8266e3a639e6a4b15f02416a3aae5173c275 /src/objcache.cpp
parente48f695c385ccc356e124ac3a851a6228f4f5b84 (diff)
downloadDoxygen-b625258a2f46f61e85bf473dfa64b719755c3b71.zip
Doxygen-b625258a2f46f61e85bf473dfa64b719755c3b71.tar.gz
Doxygen-b625258a2f46f61e85bf473dfa64b719755c3b71.tar.bz2
Release-1.7.6.1
Diffstat (limited to 'src/objcache.cpp')
-rw-r--r--src/objcache.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/objcache.cpp b/src/objcache.cpp
index d16e57c..23c14ec 100644
--- a/src/objcache.cpp
+++ b/src/objcache.cpp
@@ -22,16 +22,10 @@
//----------------------------------------------------------------------
-#ifdef CACHE_STATS
-int ObjCache::misses = 0;
-int ObjCache::hits = 0;
-#endif
-
-//----------------------------------------------------------------------
-
ObjCache::ObjCache(unsigned int logSize)
: m_head(-1), m_tail(-1), //m_numEntries(0),
- m_size(1<<logSize), m_freeHashNodes(0), m_freeCacheNodes(0), m_lastHandle(-1)
+ m_size(1<<logSize), m_count(0), m_freeHashNodes(0), m_freeCacheNodes(0),
+ m_lastHandle(-1)
{
int i;
m_cache = new CacheNode[m_size];
@@ -42,6 +36,8 @@ ObjCache::ObjCache(unsigned int logSize)
m_hash[i].nextHash = i+1;
m_cache[i].next = i+1;
}
+ m_misses = 0;
+ m_hits = 0;
}
ObjCache::~ObjCache()
@@ -61,9 +57,7 @@ int ObjCache::add(void *obj,void **victim)
{
//printf("moveToFront=%d\n",hnode->index);
moveToFront(hnode->index);
-#ifdef CACHE_STATS
- hits++;
-#endif
+ m_hits++;
}
else // object not in the cache.
{
@@ -86,6 +80,7 @@ int ObjCache::add(void *obj,void **victim)
m_cache[m_head].prev = index;
}
m_head = index;
+ m_count++;
}
else // cache full -> replace element in the cache
{
@@ -99,9 +94,7 @@ int ObjCache::add(void *obj,void **victim)
hnode = hashInsert(obj);
hnode->index = m_head;
*victim = lruObj;
-#ifdef CACHE_STATS
- misses++;
-#endif
+ m_misses++;
}
return m_head;
}
@@ -121,6 +114,7 @@ void ObjCache::del(int index)
m_cache[index].prev=-1;
m_cache[index].next = m_freeCacheNodes;
m_freeCacheNodes = index;
+ m_count--;
}
#ifdef CACHE_DEBUG
@@ -151,7 +145,7 @@ void ObjCache::printLRU()
#define cache_stats_printf printf
void ObjCache::printStats()
{
- cache_stats_printf("ObjCache: hits=%d misses=%d hit ratio=%f\n",hits,misses,hits*100.0/(hits+misses));
+ cache_stats_printf("ObjCache: hits=%d misses=%d hit ratio=%f\n",m_hits,m_misses,m_hits*100.0/(m_hits+m_misses));
}
#endif