From ff0fdbfbea248d2d74873b16392badc024b47d36 Mon Sep 17 00:00:00 2001 From: azazel Date: Mon, 25 Oct 2010 19:20:39 +0600 Subject: 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 --- src/server/game/Globals/ObjectMgr.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 63339a17170..6ada4df6211 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -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 { -- cgit v1.2.3