Skip to content

Commit ad85d1c

Browse files
authored
Use Endianness utility over BitConverter
Signed-off-by: Xen <lordofxen@deskasoft.com>
1 parent eee85c7 commit ad85d1c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

HashifyNet/Algorithms/Jenkins/JenkinsLookup3_Implementation.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ protected override IHashValue ComputeHashInternal(ArraySegment<byte> data, Cance
9999
{
100100
while (currentOffset < remainderOffset)
101101
{
102-
a += BitConverter.ToUInt32(dataArray, currentOffset);
103-
b += BitConverter.ToUInt32(dataArray, currentOffset + 4);
104-
c += BitConverter.ToUInt32(dataArray, currentOffset + 8);
102+
a += Endianness.ToUInt32LittleEndian(dataArray, currentOffset);
103+
b += Endianness.ToUInt32LittleEndian(dataArray, currentOffset + 4);
104+
c += Endianness.ToUInt32LittleEndian(dataArray, currentOffset + 8);
105105

106106
Mix(ref a, ref b, ref c);
107107

@@ -117,23 +117,23 @@ protected override IHashValue ComputeHashInternal(ArraySegment<byte> data, Cance
117117
switch (remainderCount)
118118
{
119119
case 12:
120-
c += BitConverter.ToUInt32(dataArray, currentOffset + 8);
120+
c += Endianness.ToUInt32LittleEndian(dataArray, currentOffset + 8);
121121
goto case 8;
122122

123123
case 11: c += (uint)dataArray[currentOffset + 10] << 16; goto case 10;
124124
case 10: c += (uint)dataArray[currentOffset + 9] << 8; goto case 9;
125125
case 9: c += dataArray[currentOffset + 8]; goto case 8;
126126

127127
case 8:
128-
b += BitConverter.ToUInt32(dataArray, currentOffset + 4);
128+
b += Endianness.ToUInt32LittleEndian(dataArray, currentOffset + 4);
129129
goto case 4;
130130

131131
case 7: b += (uint)dataArray[currentOffset + 6] << 16; goto case 6;
132132
case 6: b += (uint)dataArray[currentOffset + 5] << 8; goto case 5;
133133
case 5: b += dataArray[currentOffset + 4]; goto case 4;
134134

135135
case 4:
136-
a += BitConverter.ToUInt32(dataArray, currentOffset);
136+
a += Endianness.ToUInt32LittleEndian(dataArray, currentOffset);
137137

138138
Final(ref a, ref b, ref c);
139139
break;
@@ -153,11 +153,11 @@ protected override IHashValue ComputeHashInternal(ArraySegment<byte> data, Cance
153153
switch (_config.HashSizeInBits)
154154
{
155155
case 32:
156-
hash = BitConverter.GetBytes(c);
156+
hash = Endianness.GetBytesLittleEndian(c);
157157
break;
158158

159159
case 64:
160-
hash = BitConverter.GetBytes((((ulong)b) << 32) | c);
160+
hash = Endianness.GetBytesLittleEndian((((ulong)b) << 32) | c);
161161
break;
162162

163163
default:
@@ -199,4 +199,4 @@ private static uint RotateLeft(uint operand, int shiftCount)
199199
(operand >> (32 - shiftCount));
200200
}
201201
}
202-
}
202+
}

0 commit comments

Comments
 (0)