[7283] Use map for trainer spells for fast find data by spell id.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
zhenya 2009-02-15 22:47:47 +03:00 committed by VladimirMangos
parent 02b4b2f0b1
commit 22656b33e3
5 changed files with 38 additions and 42 deletions

View file

@ -46,18 +46,11 @@
// apply implementation of the singletons
#include "Policies/SingletonImp.h"
void TrainerSpellData::Clear()
{
for (TrainerSpellList::iterator itr = spellList.begin(); itr != spellList.end(); ++itr)
delete (*itr);
spellList.clear();
}
TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
{
for(TrainerSpellList::const_iterator itr = spellList.begin(); itr != spellList.end(); ++itr)
if((*itr)->spell == spell_id)
return *itr;
TrainerSpellMap::const_iterator itr = spellList.find(spell_id);
if (itr != spellList.end())
return &itr->second;
return NULL;
}