mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 00:38:47 +00:00
(#28) Use bit manipulation for ReadDecimal
Array.Copy is slightly more inefficient than direct bit shift
This commit is contained in:
parent
34ee60437b
commit
3a46d58210
@ -85,7 +85,10 @@ namespace X10D.StreamExtensions
|
|||||||
var bits = new int[partitionSize];
|
var bits = new int[partitionSize];
|
||||||
for (var index = 0; index < partitionSize; index += int32Size)
|
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);
|
return new decimal(bits);
|
||||||
|
Loading…
Reference in New Issue
Block a user