Hi Olivier,
First, thank you for your helpful post here and I'd like introduce some suggestion that might help to increase the performance of the Read & Write methods (of arrays such as ReadIntArray
, ReadFloatArray
and WriteIntArray
, .... etc.). My suggestion is to make use of the System.Buffer.BlockCopy()
that can be used to copy the items from some numeric type array to another one. For example, your ReadIntArray()
code might be replaced by:
public int[] ReadIntArray(int length)
{
int[] array = new int[length];
byte[] bytes = ReadBytes(length * 4);
System.Buffer.BlockCopy(bytes, 0, array, 0, bytes.Length);
return array;
}
and the WriteIntArray()
should be replaced by:
public void Write(int[] array)
{
byte[] bytes = new byte[4 * array.Length];
System.Buffer.BlockCopy(bytes, 0, bytes, 0, bytes.Length);
Write(bytes);
}
I hope that will help... and thanks again for your great post.
Bachelor degree of Computer Sciences, Software developer using .NET (Visual Basic & C#).
I like the development of an Artificial Intelligence Systems, GPS Applications, GDI+, APIs, N-Tier Applications, Distributed Systems and Network Monitoring Systems.
Mobile Development (Windows Mobile & Android).