The name speaks for itself. I have a file containing base64 encoded byte[]variable width integer, min 8 bit, max 32bit
I have a large file (48 MB) and I'm trying to find the fastest way to capture integers from a stream.
This is the fastest code from the main application:
static int[] Base64ToIntArray3(string base64, int size)
{
List<int> res = new List<int>();
byte[] buffer = new byte[4];
using (var ms = new System.IO.MemoryStream(Convert.FromBase64String(base64)))
{
while(ms.Position < ms.Length)
{
ms.Read(buffer, 0, size);
res.Add(BitConverter.ToInt32(buffer, 0));
}
}
return res.ToArray();
}
I do not see a faster way to fill bytes up to 32 bits. Any ideas, guys or charts? Solutions should be in C #. I could fall into C / ++ if I should, but I don't want that.
source
share