Improve AttackEntitiesByPreference by short-circuiting on best possible preference.
Similar trick to D3446 / c87229aa48
- we can short-circuit if we find
units that match our best possible preference.
This is, in particular, almost a 40% wall time improvement on Combat
Demo Huge, but it should apply in a number of more normal cases.
Differential Revision: https://code.wildfiregames.com/D5020
This was SVN commit r27701.
This commit is contained in:
parent
64efa0acf9
commit
298f207e5b
@ -6438,7 +6438,15 @@ UnitAI.prototype.AttackEntitiesByPreference = function(ents)
|
||||
if (!attackfilter(ent))
|
||||
continue;
|
||||
let pref = cmpAttack.GetPreference(ent);
|
||||
if (pref === null || pref === undefined)
|
||||
// If we match our best preference, we can try responding right away.
|
||||
// This makes some common cases fast, like most soldiers having 'Human' as best preference,
|
||||
// or ships having 'Ship'. And if there are no such targets, this doesn't do much more work.
|
||||
if (pref === 0)
|
||||
{
|
||||
if (this.RespondToTargetedEntities([ent]))
|
||||
return true;
|
||||
}
|
||||
else if (pref === null || pref === undefined)
|
||||
entsWithoutPref.push(ent);
|
||||
else if (!entsByPreferences[pref])
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user