Service caching.

This commit is contained in:
Mari the Deer 2022-07-15 09:32:16 +02:00
commit 1969eff7d9
4 changed files with 26 additions and 27 deletions

View file

@ -19,7 +19,7 @@ Class SWWMHandler : EventHandler
int iwantdie;
int indoomvacation;
int inultdoom2;
bool funtagsv;
Array<Service> funtagsv, mergemonstersv;
// for checkreplacement
bool hasdrlamonsters;
@ -91,9 +91,14 @@ Class SWWMHandler : EventHandler
bludtypes.Push(list[i]);
}
}
// check if fun tag services actually exist (can reduce overhead severely on map load if they don't, due to combat tracker tag lookups)
if ( ServiceIterator.Find("FunTagService").Next() )
funtagsv = true;
// cache various services into the handler on register
// this dramatically reduces overhead by not having to use an iterator every time they're needed
// especially noticeable for fun tags, as they're looked up for every monster on map load
let si = ServiceIterator.Find("FunTagService");
Service sv;
while ( sv = si.Next() ) funtagsv.Push(sv);
si = ServiceIterator.Find("MergeMonsterService");
while ( sv = si.Next() ) mergemonstersv.Push(sv);
// start profiling
if ( swwm_profstart <= 0 ) return;
bprofiletics = profiletics = swwm_profstart;