# HG changeset patch # User jasoka@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1216732071 0 # Node ID 69a7d40ccf626adf23903fa10706568ffc7e9913 # Parent 64e7fe3d4288f4591ce108eaef5625c06e3e84d3 added hashing to pool to improve techdemo loading time diff -r 64e7fe3d4288 -r 69a7d40ccf62 engine/core/util/resource/pool.cpp --- a/engine/core/util/resource/pool.cpp Tue Jul 22 10:04:16 2008 +0000 +++ b/engine/core/util/resource/pool.cpp Tue Jul 22 13:07:51 2008 +0000 @@ -37,6 +37,7 @@ Pool::Pool(): m_entries(), + m_location_to_entry(), m_listeners(), m_loaders(), m_curind(0) @@ -61,6 +62,7 @@ delete (*entry); } m_entries.clear(); + m_location_to_entry.clear(); } void Pool::addResourceLoader(ResourceLoader* loader) { @@ -68,20 +70,16 @@ } int Pool::addResourceFromLocation(const ResourceLocation& loc) { - std::vector::iterator it = m_entries.begin(); - int index = 0; - for (; it != m_entries.end(); it++) { - ResourceLocation* loc2 = (*it)->location; - if (*loc2 == loc) { - return index; - } - index++; + ResourceLocationToEntry::const_iterator it = m_location_to_entry.find(loc); + if (it != m_location_to_entry.end()) { + return (*it).second; } PoolEntry* entry = new PoolEntry(); entry->location = loc.clone(); m_entries.push_back(entry); - index = m_entries.size(); + size_t index = m_entries.size(); + m_location_to_entry[loc] = index; return index - 1; } diff -r 64e7fe3d4288 -r 69a7d40ccf62 engine/core/util/resource/pool.h --- a/engine/core/util/resource/pool.h Tue Jul 22 10:04:16 2008 +0000 +++ b/engine/core/util/resource/pool.h Tue Jul 22 13:07:51 2008 +0000 @@ -151,6 +151,8 @@ void findAndSetProvider(PoolEntry& entry); std::vector m_entries; + typedef std::map ResourceLocationToEntry; + ResourceLocationToEntry m_location_to_entry; std::vector m_listeners; std::vector m_loaders; int m_curind;