Switched the managed JQuad container implementation from a vector to a map. This speeds up the cache lookup time from O(n) to O(log n). Hard to see a noticeable difference on win, but it definitely feels snappier on my psp, for instance, when browsing your library for a card, or your graveyard, etc.

I'm also noticing that the GetQuad(int) variant never seems to get hit, so I suspect that the ID lookup map is redundant.  I left it alone as the JResourceManager base class forces the need for the function; I need to spend more time looking at just how much of JResourceManager we actually use at this point.
This commit is contained in:
wrenczes@gmail.com
2010-10-17 16:54:08 +00:00
parent 1071dbf738
commit 832f11c153
3 changed files with 58 additions and 42 deletions
+8 -1
View File
@@ -162,6 +162,8 @@ public:
JQuad* GetQuad(const string &quadName);
JQuad* GetQuad(int id);
int AddQuadToManaged(const WManagedQuad& inManagedQuad);
//Our file redirect system.
string graphicsFile(const string filename);
string avatarFile(const string filename);
@@ -207,7 +209,12 @@ private:
WCache<WCachedTexture,JTexture> textureWCache;
WCache<WCachedSample,JSample> sampleWCache;
WCache<WCachedParticles,hgeParticleSystemInfo> psiWCache;
vector<WManagedQuad*> managedQuads;
typedef std::map<std::string, WManagedQuad> ManagedQuadMap;
ManagedQuadMap mManagedQuads;
typedef std::map<int, std::string> IDLookupMap;
IDLookupMap mIDLookupMap;
//Statistics of record.
unsigned int lastTime;