36 internal static object[] Decompress(
object[] constantPool)
38 var list =
new List<object>();
40 foreach (var obj
in constantPool)
42 int emptySlots = obj as
byte? ?? obj as ushort? ?? 0;
45 list.Add(Unescape(obj));
49 for (
int i = 0; i < emptySlots; i++)
54 return list.ToArray();
57 static object Unescape(
object obj)
59 if (obj is
string str)
65 internal static object[] Compress(
object[] constantPool,
bool[] inUse)
67 int length = constantPool.Length;
68 while (!inUse[length - 1])
72 for (
int read = 0; read < length; read++)
78 int emptySlots = read - start;
81 constantPool[write++] = (ushort)emptySlots;
83 else if (emptySlots > 0)
85 constantPool[write++] = (byte)emptySlots;
88 constantPool[write++] = Escape(constantPool[read]);
91 Array.Resize(
ref constantPool, write);
95 static object Escape(
object obj)
97 if (obj is
string str)
103 internal readonly
object[] constantPool;
111 this.constantPool = Decompress(constantPool);