Skip to content

Commit d7ab3d7

Browse files
authored
Faster UnicodeTrie startup time (toptensoftware#73)
1 parent 4da86ac commit d7ab3d7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Topten.RichTextKit/Unicode/UnicodeTrie.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public UnicodeTrie(Stream stream)
4040
using (var bw = new BinaryReader(infl2, Encoding.UTF8, true))
4141
{
4242
_data = new int[dataLength];
43-
for (int i = 0; i < _data.Length; i++)
44-
{
45-
_data[i] = bw.ReadInt32();
46-
}
43+
44+
// Read the entire stream, then convert to int[]
45+
var byteData = bw.ReadBytes(_data.Length * sizeof(int));
46+
Buffer.BlockCopy(byteData, 0, _data, 0, byteData.Length);
4747
}
4848
}
4949

0 commit comments

Comments
 (0)