Core/Guilds:

* on load initialize guild vector with maximum available guild id (to avoid reallocations while loading);
* reserve space for more than one guild when adding guild to guild vector in case when new guild is out of available vector's size (to avoid reallocations for at least 15 next new guilds).

--HG--
branch : trunk
This commit is contained in:
azazel
2010-10-25 19:20:39 +06:00
parent 2e08f94338
commit ff0fdbfbea
+5 -3
View File
@@ -359,8 +359,10 @@ void ObjectMgr::AddGuild(Guild* pGuild)
uint32 guildId = pGuild->GetId();
// Allocate space if necessary
if (guildId >= uint32(mGuildMap.size()))
// Reserve a bit more space than necessary
mGuildMap.resize(guildId+1);
// Reserve a bit more space than necessary.
// 16 is intentional and it will allow creation of next 16 guilds happen
// without reallocation.
mGuildMap.resize(guildId + 16);
mGuildMap[guildId] = pGuild;
}
@@ -3513,9 +3515,9 @@ void ObjectMgr::LoadGuilds()
sLog.outString();
return;
}
mGuildMap.resize(m_guildId, NULL); // Reserve space and initialize storage for loading guilds
// 1. Load all guilds
uint64 rowCount = result->GetRowCount();
mGuildMap.resize(uint32(rowCount), NULL); // Reserve space and initialize storage for loading guilds
barGoLink bar(rowCount);
do
{