Skip to content

Commit 8fbd938

Browse files
authored
Rename UInt64 and UInt32 to ulong and uint, also fix spacing
Signed-off-by: Xen <lordofxen@deskasoft.com>
1 parent 3984b0c commit 8fbd938

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

HashifyNet/Algorithms/XXHash/XXHash_Implementation.cs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public XXHash_Implementation(IXXHashConfig config)
6161

6262
_config = config.Clone();
6363

64-
6564
if (!_validHashSizes.Contains(_config.HashSizeInBits))
6665
{
6766
throw new ArgumentOutOfRangeException($"{nameof(config)}.{nameof(config.HashSizeInBits)}", _config.HashSizeInBits, $"{nameof(config)}.{nameof(config.HashSizeInBits)} must be contained within xxHash.ValidHashSizes");
@@ -73,7 +72,7 @@ public override IBlockTransformer CreateBlockTransformer()
7372
switch (_config.HashSizeInBits)
7473
{
7574
case 32:
76-
return new BlockTransformer32((UInt32)_config.Seed);
75+
return new BlockTransformer32((uint)_config.Seed);
7776

7877
case 64:
7978
return new BlockTransformer64(_config.Seed);
@@ -94,12 +93,12 @@ private class BlockTransformer32
9493
374761393U
9594
};
9695

97-
private UInt32 _seed;
96+
private uint _seed;
9897

99-
private UInt32 _a;
100-
private UInt32 _b;
101-
private UInt32 _c;
102-
private UInt32 _d;
98+
private uint _a;
99+
private uint _b;
100+
private uint _c;
101+
private uint _d;
103102

104103
private ulong _bytesProcessed = 0;
105104

@@ -109,7 +108,7 @@ public BlockTransformer32()
109108

110109
}
111110

112-
public BlockTransformer32(UInt32 seed)
111+
public BlockTransformer32(uint seed)
113112
: this()
114113
{
115114
_seed = seed;
@@ -179,7 +178,7 @@ protected override void TransformByteGroupsInternal(ArraySegment<byte> data)
179178

180179
protected override IHashValue FinalizeHashValueInternal(CancellationToken cancellationToken)
181180
{
182-
UInt32 hashValue;
181+
uint hashValue;
183182
{
184183
if (_bytesProcessed > 0)
185184
{
@@ -194,7 +193,7 @@ protected override IHashValue FinalizeHashValueInternal(CancellationToken cancel
194193
var remainder = FinalizeInputBuffer;
195194
var remainderLength = (remainder?.Length).GetValueOrDefault();
196195

197-
hashValue += (UInt32)(_bytesProcessed + (ulong)remainderLength);
196+
hashValue += (uint)(_bytesProcessed + (ulong)remainderLength);
198197

199198
if (remainderLength > 0)
200199
{
@@ -233,7 +232,7 @@ protected override IHashValue FinalizeHashValueInternal(CancellationToken cancel
233232
32);
234233
}
235234

236-
private static UInt32 RotateLeft(UInt32 operand, int shiftCount)
235+
private static uint RotateLeft(uint operand, int shiftCount)
237236
{
238237
shiftCount &= 0x1f;
239238

@@ -246,7 +245,7 @@ private static UInt32 RotateLeft(UInt32 operand, int shiftCount)
246245
private class BlockTransformer64
247246
: BlockTransformerBase<BlockTransformer64>
248247
{
249-
private static readonly IReadOnlyList<UInt64> _primes64 =
248+
private static readonly IReadOnlyList<ulong> _primes64 =
250249
new[] {
251250
11400714785074694791UL,
252251
14029467366897019727UL,
@@ -255,12 +254,12 @@ private class BlockTransformer64
255254
2870177450012600261UL
256255
};
257256

258-
private UInt64 _seed;
257+
private ulong _seed;
259258

260-
private UInt64 _a;
261-
private UInt64 _b;
262-
private UInt64 _c;
263-
private UInt64 _d;
259+
private ulong _a;
260+
private ulong _b;
261+
private ulong _c;
262+
private ulong _d;
264263

265264
private ulong _bytesProcessed = 0;
266265

@@ -269,7 +268,7 @@ public BlockTransformer64()
269268
{
270269
}
271270

272-
public BlockTransformer64(UInt64 seed)
271+
public BlockTransformer64(ulong seed)
273272
: this()
274273
{
275274
_seed = seed;
@@ -339,7 +338,7 @@ protected override void TransformByteGroupsInternal(ArraySegment<byte> data)
339338

340339
protected override IHashValue FinalizeHashValueInternal(CancellationToken cancellationToken)
341340
{
342-
UInt64 hashValue;
341+
ulong hashValue;
343342
{
344343
if (_bytesProcessed > 0)
345344
{
@@ -381,7 +380,6 @@ protected override IHashValue FinalizeHashValueInternal(CancellationToken cancel
381380

382381
hashValue ^= tempD;
383382
hashValue = (hashValue * _primes64[0]) + _primes64[3];
384-
385383
}
386384
else
387385
{
@@ -392,11 +390,10 @@ protected override IHashValue FinalizeHashValueInternal(CancellationToken cancel
392390
var remainder = FinalizeInputBuffer;
393391
var remainderLength = (remainder?.Length).GetValueOrDefault();
394392

395-
hashValue += _bytesProcessed + (UInt64)remainderLength;
393+
hashValue += _bytesProcessed + (ulong)remainderLength;
396394

397395
if (remainderLength > 0)
398396
{
399-
400397
// In 8-byte chunks, process all full chunks
401398
for (int x = 0; x < remainder.Length / 8; ++x)
402399
{
@@ -437,7 +434,7 @@ protected override IHashValue FinalizeHashValueInternal(CancellationToken cancel
437434
64);
438435
}
439436

440-
private static UInt64 RotateLeft(UInt64 operand, int shiftCount)
437+
private static ulong RotateLeft(ulong operand, int shiftCount)
441438
{
442439
shiftCount &= 0x3f;
443440

@@ -447,4 +444,4 @@ private static UInt64 RotateLeft(UInt64 operand, int shiftCount)
447444
}
448445
}
449446
}
450-
}
447+
}

0 commit comments

Comments
 (0)