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
|
|
@ -14,8 +14,8 @@
|
|||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Collections;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
|
|
@ -112,24 +112,25 @@ public static class IncomingItemPackets
|
|||
public static void EquipMacro(NetState state, SpanReader reader)
|
||||
{
|
||||
int count = reader.ReadByte();
|
||||
var serialList = new List<Serial>(count);
|
||||
var serialList = PooledRefList<Serial>.Create(count);
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
serialList.Add((Serial)reader.ReadUInt32());
|
||||
}
|
||||
|
||||
PlayerMobile.EquipMacro(state.Mobile, serialList);
|
||||
PlayerMobile.EquipMacro(state.Mobile, ref serialList);
|
||||
serialList.Dispose();
|
||||
}
|
||||
|
||||
public static void UnequipMacro(NetState state, SpanReader reader)
|
||||
{
|
||||
int count = reader.ReadByte();
|
||||
var layers = new List<Layer>(count);
|
||||
var layers = PooledRefList<Layer>.Create(count);
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
layers.Add((Layer)reader.ReadUInt16());
|
||||
}
|
||||
|
||||
PlayerMobile.UnequipMacro(state.Mobile, layers);
|
||||
PlayerMobile.UnequipMacro(state.Mobile, ref layers);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue