fix: Eliminates List allocations in various places. (#2158)
This commit is contained in:
parent
6f64cddd0b
commit
4836bff5eb
23 changed files with 263 additions and 200 deletions
|
|
@ -1235,24 +1235,24 @@ namespace Server.Multis
|
|||
return list;
|
||||
}
|
||||
|
||||
public List<Mobile> GetMobiles()
|
||||
public PooledRefList<Mobile> GetMobilesPooled()
|
||||
{
|
||||
if (Map == null || Map == Map.Internal)
|
||||
{
|
||||
return new List<Mobile>();
|
||||
return PooledRefList<Mobile>.Create(0);
|
||||
}
|
||||
|
||||
var list = new List<Mobile>();
|
||||
|
||||
foreach (var mobile in Region.GetMobiles())
|
||||
var mobileList = Region.GetMobilesPooled();
|
||||
for (var i = mobileList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (IsInside(mobile))
|
||||
var mobile = mobileList[i];
|
||||
if (!IsInside(mobile))
|
||||
{
|
||||
list.Add(mobile);
|
||||
mobileList.Remove(mobile);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return mobileList;
|
||||
}
|
||||
|
||||
public virtual bool CheckAosLockdowns(int need) => GetAosCurLockdowns() + need <= GetAosMaxLockdowns();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue