@@ -50,7 +50,7 @@ internal class CRC_Implementation
5050 public override ICRCConfig Config => _config . Clone ( ) ;
5151
5252 private readonly ICRCConfig _config ;
53- private static readonly ConcurrentDictionary < ( int , UInt64 , bool ) , IReadOnlyList < UInt64 > > _dataDivisionTableCache =
53+ private static readonly ConcurrentDictionary < ( int , ulong , bool ) , IReadOnlyList < ulong > > _dataDivisionTableCache =
5454 new ConcurrentDictionary < ( int , ulong , bool ) , IReadOnlyList < ulong > > ( ) ;
5555
5656 public CRC_Implementation ( ICRCConfig config )
@@ -75,12 +75,12 @@ private class BlockTransformer
7575 : BlockTransformerBase < BlockTransformer >
7676 {
7777 private int _hashSizeInBits ;
78- private IReadOnlyList < UInt64 > _crcTable ;
78+ private IReadOnlyList < ulong > _crcTable ;
7979 private int _mostSignificantShift ;
8080 private bool _reflectIn ;
8181 private bool _reflectOut ;
82- private UInt64 _xOrOut ;
83- private UInt64 _hashValue ;
82+ private ulong _xOrOut ;
83+ private ulong _hashValue ;
8484
8585 public BlockTransformer ( )
8686 : base ( )
@@ -178,7 +178,6 @@ protected override void TransformByteGroupsInternal(ArraySegment<byte> data)
178178 tempHashValue = ( tempHashValue << 1 ) ^ tempCrcTable [ ( byte ) ( ( tempHashValue >> tempMostSignificantShift ) & 1 ) ^ ( ( byte ) ( dataArray [ currentOffset ] >> ( 7 - currentBit ) ) & 1 ) ] ;
179179 }
180180 }
181-
182181 }
183182 }
184183
@@ -217,14 +216,14 @@ protected override IHashValue FinalizeHashValueInternal(CancellationToken cancel
217216 /// The table accounts for reflecting the index bits to fix the input endianness,
218217 /// but it is not possible completely account for the output endianness if the CRC is mixed-endianness.
219218 /// </remarks>
220- private static IReadOnlyList < UInt64 > GetDataDivisionTable ( int hashSizeInBits , UInt64 polynomial , bool reflectIn )
219+ private static IReadOnlyList < ulong > GetDataDivisionTable ( int hashSizeInBits , ulong polynomial , bool reflectIn )
221220 {
222221 return _dataDivisionTableCache . GetOrAdd (
223222 ( hashSizeInBits , polynomial , reflectIn ) ,
224223 GetDataDivisionTableInternal ) ;
225224 }
226225
227- private static IReadOnlyList < UInt64 > GetDataDivisionTableInternal ( ( int , UInt64 , bool ) cacheKey )
226+ private static IReadOnlyList < ulong > GetDataDivisionTableInternal ( ( int , ulong , bool ) cacheKey )
228227 {
229228 var hashSizeInBits = cacheKey . Item1 ;
230229 var polynomial = cacheKey . Item2 ;
@@ -236,12 +235,12 @@ private static IReadOnlyList<UInt64> GetDataDivisionTableInternal((int, UInt64,
236235 perBitCount = 1 ;
237236 }
238237
239- var crcTable = new UInt64 [ 1 << perBitCount ] ;
238+ var crcTable = new ulong [ 1 << perBitCount ] ;
240239 var mostSignificantBit = 1UL << ( hashSizeInBits - 1 ) ;
241240
242241 for ( uint x = 0 ; x < crcTable . Length ; ++ x )
243242 {
244- UInt64 curValue = x ;
243+ ulong curValue = x ;
245244
246245 if ( perBitCount > 1 && reflectIn )
247246 {
@@ -267,18 +266,17 @@ private static IReadOnlyList<UInt64> GetDataDivisionTableInternal((int, UInt64,
267266 curValue = ReflectBits ( curValue , hashSizeInBits ) ;
268267 }
269268
270- curValue &= UInt64 . MaxValue >> ( 64 - hashSizeInBits ) ;
269+ curValue &= ulong . MaxValue >> ( 64 - hashSizeInBits ) ;
271270
272271 crcTable [ x ] = curValue ;
273272 }
274273
275274 return crcTable ;
276275 }
277276
278-
279- private static byte [ ] ToBytes ( UInt64 value , int bitLength )
277+ private static byte [ ] ToBytes ( ulong value , int bitLength )
280278 {
281- value &= UInt64 . MaxValue >> ( 64 - bitLength ) ;
279+ value &= ulong . MaxValue >> ( 64 - bitLength ) ;
282280
283281 var valueBytes = new byte [ ( bitLength + 7 ) / 8 ] ;
284282
@@ -291,9 +289,9 @@ private static byte[] ToBytes(UInt64 value, int bitLength)
291289 return valueBytes ;
292290 }
293291
294- private static UInt64 ReflectBits ( UInt64 value , int bitLength )
292+ private static ulong ReflectBits ( ulong value , int bitLength )
295293 {
296- UInt64 reflectedValue = 0UL ;
294+ ulong reflectedValue = 0UL ;
297295
298296 for ( int x = 0 ; x < bitLength ; ++ x )
299297 {
@@ -308,4 +306,4 @@ private static UInt64 ReflectBits(UInt64 value, int bitLength)
308306 }
309307 }
310308 }
311- }
309+ }
0 commit comments