Jeck - Removed a ton of unreached or unused code from the cache, to make debugging easier. None of this actually effects execution at all. Some of these functions (though not many) are potentially useful, but as they aren't actually used there's no reason to have them cluttering up the files.

This commit is contained in:
wagic.jeck
2009-10-26 05:55:52 +00:00
parent eefd03ad84
commit 8e0bcef6e9
4 changed files with 4 additions and 137 deletions

View File

@@ -16,8 +16,6 @@ public:
WResource();
virtual ~WResource();
virtual void Trash()=0; //Delete the cacheActual.
virtual void Nullify()=0; //For when our size is 0, so we don't free anything by mistake.
virtual unsigned long size()=0; //Size of cached item in bytes.
virtual bool isGood()=0; //Return true if this has data.
virtual bool isLocked(); //Is the resource locked?
@@ -51,8 +49,6 @@ class WTrackedQuad: public WResource {
public:
WTrackedQuad(string _resname);
~WTrackedQuad();
void Nullify();
void Trash();
bool isGood();
unsigned long size();
string resname;
@@ -72,9 +68,6 @@ public:
bool isLocked();
bool Attempt(string filename, int submode, int & error);
bool compare(JTexture * t) {return (t == texture);};
void Nullify();
void Trash();
JTexture * Actual(); //Return this texture as is. Does not make a new one.
JQuad * GetQuad(string resname);
@@ -87,7 +80,6 @@ public:
protected:
JTexture * texture;
vector<WTrackedQuad*> trackedQuads;
static vector<WTrackedQuad*> garbageTQs;
};
class WCachedParticles: public WCachedResource{
@@ -96,11 +88,8 @@ public:
template<class cacheItem,class cacheActual> friend class WCache;
WCachedParticles();
~WCachedParticles();
void Nullify();
void Trash();
void Refresh();
unsigned long size();
unsigned long size();
bool isGood();
bool Attempt(string filename, int submode, int & error);
@@ -117,8 +106,6 @@ public:
template<class cacheItem,class cacheActual> friend class WCache;
WCachedSample();
~WCachedSample();
void Nullify();
void Trash();
bool compare(JSample * s) {return (s == sample);};
unsigned long size();
bool isGood();

View File

@@ -80,9 +80,7 @@ public:
bool RemoveMiss(int id=0); //Removes a cache miss.
bool RemoveOldest(); //Remove oldest unlocked item.
bool Cleanup(); //Repeats RemoveOldest() until cache fits in size limits
void Clear(); //Removes everything cached. Not lock safe, does not remove managed items.
void ClearUnlocked(); //Remove all unlocked items.
void ClearMisses(); //Clear all cache misses.
void Refresh(); //Refreshes all cache items.
unsigned int Flatten(); //Ensures that the times don't loop. Returns new lastTime.
void Resize(unsigned long size, int items); //Sets new limits, then enforces them. Lock safe, so not a "hard limit".
@@ -108,8 +106,6 @@ protected:
unsigned int cacheItems;
int mError;
};
@@ -139,7 +135,6 @@ public:
bool RemoveOldest();
bool Cleanup(); //Force a cleanup. Return false if nothing removed.
void ClearMisses(); //Remove all cache misses.
void ClearUnlocked(); //Remove unlocked items.
void Refresh(); //Refreshes all files in cache, for when mode/profile changes.

View File

@@ -60,8 +60,6 @@ void WResource::hit(){
lastTime = resources.nowTime();
}
//WCachedTexture
vector<WTrackedQuad*> WCachedTexture::garbageTQs;
WCachedTexture::WCachedTexture(){
texture = NULL;
}
@@ -112,14 +110,8 @@ bool WCachedTexture::ReleaseQuad(JQuad* quad){
tq->unlock();
if(!tq->isLocked()){
if(WCachedTexture::garbageTQs.size() < MAX_CACHE_GARBAGE){
tq->Trash();
garbageTQs.push_back(tq);
}
else
SAFE_DELETE(tq);
trackedQuads.erase(it);
trackedQuads.erase(it);
}
return true; //Returns true when found.
@@ -307,39 +299,7 @@ bool WCachedTexture::Attempt(string filename, int submode, int & error){
return true;
}
void WCachedTexture::Nullify(){
if(texture)
texture = NULL;
}
void WCachedTexture::Trash(){
SAFE_DELETE(texture);
vector<WTrackedQuad*>::iterator it;
WTrackedQuad * tq = NULL;
for(it=trackedQuads.begin();it!=trackedQuads.end();it++){
tq = (*it);
if(WCachedTexture::garbageTQs.size() > MAX_CACHE_GARBAGE)
SAFE_DELETE(tq);
else{
tq->Trash();
WCachedTexture::garbageTQs.push_back(tq);
}
}
trackedQuads.clear();
}
//WCachedSample
void WCachedSample::Nullify(){
if(sample){
sample = NULL;
}
}
void WCachedSample::Trash(){
SAFE_DELETE(sample);
}
WCachedSample::WCachedSample(){
sample = NULL;
}
@@ -454,25 +414,7 @@ WCachedParticles::~WCachedParticles(){
SAFE_DELETE(particles);
}
void WCachedParticles::Nullify(){
if(particles)
particles = NULL;
}
void WCachedParticles::Trash(){
SAFE_DELETE(particles);
}
//WTrackedQuad
void WTrackedQuad::Nullify() {
quad = NULL;
}
void WTrackedQuad::Trash(){
resname.clear();
SAFE_DELETE(quad);
}
unsigned long WTrackedQuad::size() {
return sizeof(JQuad);
}

View File

@@ -181,13 +181,6 @@ WResourceManager::~WResourceManager(){
SAFE_DELETE(wm);
}
managedQuads.clear();
//Remove all our reserved WTrackedQuads from WCachedTexture
vector<WTrackedQuad*>::iterator g;
for(g=WCachedTexture::garbageTQs.begin();g!=WCachedTexture::garbageTQs.end();g++){
WTrackedQuad * tq = *g;
SAFE_DELETE(tq);
}
LOG("==Successfully Destroyed WResourceManager==");
}
@@ -356,13 +349,6 @@ void WResourceManager::Release(JQuad * quad){
if(it != textureWCache.cache.end() && it->second)
textureWCache.RemoveItem(it->second,false); //won't remove locked.
}
void WResourceManager::ClearMisses(){
textureWCache.ClearMisses();
sampleWCache.ClearMisses();
psiWCache.ClearMisses();
}
void WResourceManager::ClearUnlocked(){
textureWCache.ClearUnlocked();
sampleWCache.ClearUnlocked();
@@ -889,27 +875,6 @@ bool WCache<cacheItem, cacheActual>::RemoveOldest(){
return false;
}
template <class cacheItem, class cacheActual>
void WCache<cacheItem, cacheActual>::Clear(){
typename map<int,cacheItem*>::iterator it, next;
for(it = cache.begin(); it != cache.end();it=next){
next = it;
next++;
if(it->second)
Delete(it->second);
cache.erase(it);
}
for(it = managed.begin(); it != managed.end();it=next){
next = it;
next++;
if(!it->second)
managed.erase(it);
}
}
template <class cacheItem, class cacheActual>
void WCache<cacheItem, cacheActual>::ClearUnlocked(){
typename map<int,cacheItem*>::iterator it, next;
@@ -927,31 +892,11 @@ void WCache<cacheItem, cacheActual>::ClearUnlocked(){
}
}
}
template <class cacheItem, class cacheActual>
void WCache<cacheItem, cacheActual>::ClearMisses(){
typename map<int,cacheItem*>::iterator it, next;
for(it = cache.begin(); it != cache.end();it=next){
next = it;
next++;
if(!it->second)
cache.erase(it);
}
for(it = managed.begin(); it != managed.end();it=next){
next = it;
next++;
if(!it->second)
managed.erase(it);
}
}
template <class cacheItem, class cacheActual>
void WCache<cacheItem, cacheActual>::Resize(unsigned long size, int items){
maxCacheSize = size;
if(items > MAX_CACHE_OBJECTS || items < 0)
if(items > MAX_CACHE_OBJECTS || items < 1)
maxCached = MAX_CACHE_OBJECTS;
else
maxCached = items;
@@ -1200,7 +1145,7 @@ bool WCache<cacheItem, cacheActual>::Cleanup(){
template <class cacheItem, class cacheActual>
unsigned int WCache<cacheItem, cacheActual>::Flatten(){
unsigned int youngest = 65535;
unsigned int youngest = (unsigned int) 65535;
unsigned int oldest = 0;
for (typename map<int,cacheItem*>::iterator it = cache.begin(); it != cache.end(); ++it){
@@ -1283,8 +1228,6 @@ template <class cacheItem, class cacheActual>
bool WCache<cacheItem, cacheActual>::Delete(cacheItem * item){
if(!item)
return false;
if(maxCached == 0)
item->Nullify();
unsigned long isize = item->size();
totalSize -= isize;