1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:58:48 +00:00

(#28) Use bit manipulation for ReadDecimal

Array.Copy is slightly more inefficient than direct bit shift
This commit is contained in:
Oliver Booth 2021-03-03 19:09:20 +00:00
parent 34ee60437b
commit 3a46d58210

View File

@ -85,7 +85,10 @@ namespace X10D.StreamExtensions
var bits = new int[partitionSize];
for (var index = 0; index < partitionSize; index += int32Size)
{
Array.Copy(buffer, index, bits, 0, int32Size);
bits[index] = (buffer[index + 0] << 24) // +0 because aligned code is best code
| (buffer[index + 1] << 16)
| (buffer[index + 2] << 8)
| (buffer[index + 3] << 0); // don't @ me
}
return new decimal(bits);