ace/Source/ACE.DatLoader/DatDirectoryHeader.cs
FlaggAC 7f1b58ab24
Change static readonly fields to const fields. (#4211)
This will at least somewhat improve performance, as confirmed through microbenchmark testing.

const fields are replaced with literal values in the Assembly's IL code, while static readonly fields may be optimized by the JIT, and is not guaranteed to happen. const fields may also lend themselves to stronger optimizations at runtime.
2024-08-24 14:32:35 +00:00

29 lines
820 B
C#

using System.IO;
namespace ACE.DatLoader
{
public class DatDirectoryHeader : IUnpackable
{
internal const uint ObjectSize = ((sizeof(uint) * 0x3E) + sizeof(uint) + (DatFile.ObjectSize * 0x3D));
public uint[] Branches { get; } = new uint[0x3E];
public uint EntryCount { get; private set; }
public DatFile[] Entries { get; private set; }
public void Unpack(BinaryReader reader)
{
for (int i = 0; i < Branches.Length; i++)
Branches[i] = reader.ReadUInt32();
EntryCount = reader.ReadUInt32();
Entries = new DatFile[EntryCount];
for (int i = 0; i < EntryCount; i++)
{
Entries[i] = new DatFile();
Entries[i].Unpack(reader);
}
}
}
}