A pure CLS-compliant C# implementation of the Named Binary Tag (NBT) format specification commonly used with Minecraft applications, allowing easy reading/writing streams and serialization to other formats.
The TagReader and TagWriter class still use the naive and legacy method of BitConverter.GetBytes paired with Array.Reverse to get the correct byte-order.
Replace all these method calls with the use of stackalloc spans and employ BinaryPrimitives methods to read/write in the appropriate endian. This will make them free of any heap-allocations in additional to being computationally less expensive.
The
TagReader
andTagWriter
class still use the naive and legacy method ofBitConverter.GetBytes
paired withArray.Reverse
to get the correct byte-order.Replace all these method calls with the use of
stackalloc
spans and employBinaryPrimitives
methods to read/write in the appropriate endian. This will make them free of any heap-allocations in additional to being computationally less expensive.