fix: Removes custom BitArray (#1597)

### Summary

The BitArray class will be optimized over the next several years for various platforms/hardware and maintaining a duplicate for serialization is not practical. Removing the custom implementation. Recommend against using BitArray for serialization unless it is absolutely necessary.
This commit is contained in:
Kamron Batman 2023-11-17 14:37:07 -08:00 • committed by GitHub
parent a1dffd10ce
commit e9642d61f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 1489 deletions

View file

@ -14,9 +14,13 @@
*************************************************************************/
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using Server.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Server;
@ -162,7 +166,17 @@ public interface IGenericWriter
Write(stack);
}
void Write(BitArray bitArray);
public void Write(BitArray bitArray)
{
var bytesLength = (bitArray.Length - 1 + (1 << 3)) >>> 3;
var arrayBuffer = ArrayPool<byte>.Shared.Rent(bytesLength);
WriteEncodedInt(bytesLength);
bitArray.CopyTo(arrayBuffer, 0);
Write(arrayBuffer.AsSpan(0, bytesLength));
ArrayPool<byte>.Shared.Return(arrayBuffer);
}
void Write(TextDefinition def)
{