Some replacements .count to .find for better performance - original patch by zhenya.

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2010-01-16 19:18:53 +03:00
parent 706718b28c
commit 9be16cf605
3 changed files with 15 additions and 15 deletions
+11 -11
View File
@@ -1187,7 +1187,7 @@ void LoadLootTemplates_Creature()
{ {
if (uint32 lootid = cInfo->lootid) if (uint32 lootid = cInfo->lootid)
{ {
if (!ids_set.count(lootid)) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Creature.ReportNotExistedId(lootid); LootTemplates_Creature.ReportNotExistedId(lootid);
else else
ids_setUsed.insert(lootid); ids_setUsed.insert(lootid);
@@ -1213,7 +1213,7 @@ void LoadLootTemplates_Disenchant()
{ {
if (uint32 lootid = proto->DisenchantID) if (uint32 lootid = proto->DisenchantID)
{ {
if (!ids_set.count(lootid)) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Disenchant.ReportNotExistedId(lootid); LootTemplates_Disenchant.ReportNotExistedId(lootid);
else else
ids_setUsed.insert(lootid); ids_setUsed.insert(lootid);
@@ -1234,7 +1234,7 @@ void LoadLootTemplates_Fishing()
// remove real entries and check existence loot // remove real entries and check existence loot
for (uint32 i = 1; i < sAreaStore.GetNumRows(); ++i) for (uint32 i = 1; i < sAreaStore.GetNumRows(); ++i)
if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i)) if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i))
if (ids_set.count(areaEntry->ID)) if (ids_set.find(areaEntry->ID) != ids_set.end())
ids_set.erase(areaEntry->ID); ids_set.erase(areaEntry->ID);
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
@@ -1253,7 +1253,7 @@ void LoadLootTemplates_Gameobject()
{ {
if (uint32 lootid = gInfo->GetLootId()) if (uint32 lootid = gInfo->GetLootId())
{ {
if (objmgr.IsGoOfSpecificEntrySpawned(gInfo->id) && !ids_set.count(lootid)) if (objmgr.IsGoOfSpecificEntrySpawned(gInfo->id) && ids_set.find(lootid) == ids_set.end())
LootTemplates_Gameobject.ReportNotExistedId(lootid); LootTemplates_Gameobject.ReportNotExistedId(lootid);
else else
ids_setUsed.insert(lootid); ids_setUsed.insert(lootid);
@@ -1275,7 +1275,7 @@ void LoadLootTemplates_Item()
// remove real entries and check existence loot // remove real entries and check existence loot
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i) for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
if (ItemPrototype const *proto = sItemStorage.LookupEntry<ItemPrototype>(i)) if (ItemPrototype const *proto = sItemStorage.LookupEntry<ItemPrototype>(i))
if (ids_set.count(proto->ItemId)) if (ids_set.find(proto->ItemId) != ids_set.end())
ids_set.erase(proto->ItemId); ids_set.erase(proto->ItemId);
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
@@ -1297,7 +1297,7 @@ void LoadLootTemplates_Milling()
if ((proto->BagFamily & BAG_FAMILY_MASK_HERBS) == 0) if ((proto->BagFamily & BAG_FAMILY_MASK_HERBS) == 0)
continue; continue;
if (ids_set.count(proto->ItemId)) if (ids_set.find(proto->ItemId) != ids_set.end())
ids_set.erase(proto->ItemId); ids_set.erase(proto->ItemId);
} }
@@ -1317,7 +1317,7 @@ void LoadLootTemplates_Pickpocketing()
{ {
if(uint32 lootid = cInfo->pickpocketLootId) if(uint32 lootid = cInfo->pickpocketLootId)
{ {
if(!ids_set.count(lootid)) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Pickpocketing.ReportNotExistedId(lootid); LootTemplates_Pickpocketing.ReportNotExistedId(lootid);
else else
ids_setUsed.insert(lootid); ids_setUsed.insert(lootid);
@@ -1346,7 +1346,7 @@ void LoadLootTemplates_Prospecting()
if ((proto->BagFamily & BAG_FAMILY_MASK_MINING_SUPP) == 0) if ((proto->BagFamily & BAG_FAMILY_MASK_MINING_SUPP) == 0)
continue; continue;
if (ids_set.count(proto->ItemId)) if (ids_set.find(proto->ItemId) != ids_set.end())
ids_set.erase(proto->ItemId); ids_set.erase(proto->ItemId);
} }
@@ -1362,7 +1362,7 @@ void LoadLootTemplates_Mail()
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i) for(uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
if(sMailTemplateStore.LookupEntry(i)) if(sMailTemplateStore.LookupEntry(i))
if(ids_set.count(i)) if (ids_set.find(i) != ids_set.end())
ids_set.erase(i); ids_set.erase(i);
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
@@ -1381,7 +1381,7 @@ void LoadLootTemplates_Skinning()
{ {
if (uint32 lootid = cInfo->SkinLootId) if (uint32 lootid = cInfo->SkinLootId)
{ {
if (!ids_set.count(lootid)) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Skinning.ReportNotExistedId(lootid); LootTemplates_Skinning.ReportNotExistedId(lootid);
else else
ids_setUsed.insert(lootid); ids_setUsed.insert(lootid);
@@ -1411,7 +1411,7 @@ void LoadLootTemplates_Spell()
if( !IsLootCraftingSpell(spellInfo)) if( !IsLootCraftingSpell(spellInfo))
continue; continue;
if(!ids_set.count(spell_id)) if (ids_set.find(spell_id) == ids_set.end())
{ {
// not report about not trainable spells (optionally supported by DB) // not report about not trainable spells (optionally supported by DB)
// ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example // ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example
+2 -2
View File
@@ -8112,7 +8112,7 @@ void ObjectMgr::LoadTrainerSpell()
if(!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER)) if(!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER))
{ {
if(skip_trainers.count(entry) == 0) if (skip_trainers.find(entry) == skip_trainers.end())
{ {
sLog.outErrorDb("Table `npc_trainer` have data for not creature template (Entry: %u) without trainer flag, ignore", entry); sLog.outErrorDb("Table `npc_trainer` have data for not creature template (Entry: %u) without trainer flag, ignore", entry);
skip_trainers.insert(entry); skip_trainers.insert(entry);
@@ -8663,7 +8663,7 @@ void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids)
if(!GetTrinityStringLocale (itrM->second.dataint)) if(!GetTrinityStringLocale (itrM->second.dataint))
sLog.outErrorDb( "Table `db_script_string` not has string id %u used db script (ID: %u)", itrM->second.dataint, itrMM->first); sLog.outErrorDb( "Table `db_script_string` not has string id %u used db script (ID: %u)", itrM->second.dataint, itrMM->first);
if(ids.count(itrM->second.dataint)) if (ids.find(itrM->second.dataint) != ids.end())
ids.erase(itrM->second.dataint); ids.erase(itrM->second.dataint);
} }
} }
+2 -2
View File
@@ -91,7 +91,7 @@ void LoadSkillDiscoveryTable()
SpellEntry const* reqSpellEntry = sSpellStore.LookupEntry(reqSkillOrSpell); SpellEntry const* reqSpellEntry = sSpellStore.LookupEntry(reqSkillOrSpell);
if (!reqSpellEntry) if (!reqSpellEntry)
{ {
if(reportedReqSpells.count(reqSkillOrSpell)==0) if (reportedReqSpells.find(reqSkillOrSpell) == reportedReqSpells.end())
{ {
sLog.outErrorDb("Spell (ID: %u) have not existed spell (ID: %i) in `reqSpell` field in `skill_discovery_template` table",spellId,reqSkillOrSpell); sLog.outErrorDb("Spell (ID: %u) have not existed spell (ID: %i) in `reqSpell` field in `skill_discovery_template` table",spellId,reqSkillOrSpell);
reportedReqSpells.insert(reqSkillOrSpell); reportedReqSpells.insert(reqSkillOrSpell);
@@ -104,7 +104,7 @@ void LoadSkillDiscoveryTable()
// explicit discovery ability // explicit discovery ability
!IsExplicitDiscoverySpell(reqSpellEntry)) !IsExplicitDiscoverySpell(reqSpellEntry))
{ {
if (reportedReqSpells.count(reqSkillOrSpell)==0) if (reportedReqSpells.find(reqSkillOrSpell) == reportedReqSpells.end())
{ {
sLog.outErrorDb("Spell (ID: %u) not have MECHANIC_DISCOVERY (28) value in Mechanic field in spell.dbc" sLog.outErrorDb("Spell (ID: %u) not have MECHANIC_DISCOVERY (28) value in Mechanic field in spell.dbc"
" and not 100%% chance random discovery ability but listed for spellId %u (and maybe more) in `skill_discovery_template` table", " and not 100%% chance random discovery ability but listed for spellId %u (and maybe more) in `skill_discovery_template` table",