Skip to content

Commit b23da6e

Browse files
committed
refactor away from HlpNullable
1 parent ba4f1a7 commit b23da6e

17 files changed

Lines changed: 97 additions & 357 deletions

HashLib.Benchmark/Delphi/PerformanceBenchmarkConsole.dpr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ uses
7474
HlpMurmurHash3_x86_32 in '..\..\HashLib\src\Hash32\HlpMurmurHash3_x86_32.pas',
7575
HlpMurmurHash3_x86_128 in '..\..\HashLib\src\Hash128\HlpMurmurHash3_x86_128.pas',
7676
HlpSipHash128 in '..\..\HashLib\src\Hash128\HlpSipHash128.pas',
77-
HlpNullable in '..\..\HashLib\src\Nullable\HlpNullable.pas',
7877
HlpNullDigest in '..\..\HashLib\src\NullDigest\HlpNullDigest.pas',
7978
HlpOneAtTime in '..\..\HashLib\src\Hash32\HlpOneAtTime.pas',
8079
HlpPJW in '..\..\HashLib\src\Hash32\HlpPJW.pas',

HashLib.Benchmark/Delphi/PerformanceBenchmarkFMX.dpr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ uses
7373
HlpMurmurHash3_x86_32 in '..\..\HashLib\src\Hash32\HlpMurmurHash3_x86_32.pas',
7474
HlpMurmurHash3_x86_128 in '..\..\HashLib\src\Hash128\HlpMurmurHash3_x86_128.pas',
7575
HlpSipHash128 in '..\..\HashLib\src\Hash128\HlpSipHash128.pas',
76-
HlpNullable in '..\..\HashLib\src\Nullable\HlpNullable.pas',
7776
HlpNullDigest in '..\..\HashLib\src\NullDigest\HlpNullDigest.pas',
7877
HlpOneAtTime in '..\..\HashLib\src\Hash32\HlpOneAtTime.pas',
7978
HlpPJW in '..\..\HashLib\src\Hash32\HlpPJW.pas',

HashLib.Tests/Delphi.Tests/HashLib.Tests.TestInsight.dpr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ uses
114114
HlpPBKDF_Argon2NotBuildInAdapter in '..\..\HashLib\src\KDF\HlpPBKDF_Argon2NotBuildInAdapter.pas',
115115
HlpArgon2TypeAndVersion in '..\..\HashLib\src\KDF\HlpArgon2TypeAndVersion.pas',
116116
HlpPBKDF_ScryptNotBuildInAdapter in '..\..\HashLib\src\KDF\HlpPBKDF_ScryptNotBuildInAdapter.pas',
117-
HlpNullable in '..\..\HashLib\src\Nullable\HlpNullable.pas',
118117
HlpConverters in '..\..\HashLib\src\Utils\HlpConverters.pas',
119118
HlpBitConverter in '..\..\HashLib\src\Utils\HlpBitConverter.pas',
120119
HlpBits in '..\..\HashLib\src\Utils\HlpBits.pas',

HashLib.Tests/Delphi.Tests/HashLib.Tests.dpr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ uses
117117
HlpPBKDF_Argon2NotBuildInAdapter in '..\..\HashLib\src\KDF\HlpPBKDF_Argon2NotBuildInAdapter.pas',
118118
HlpArgon2TypeAndVersion in '..\..\HashLib\src\KDF\HlpArgon2TypeAndVersion.pas',
119119
HlpPBKDF_ScryptNotBuildInAdapter in '..\..\HashLib\src\KDF\HlpPBKDF_ScryptNotBuildInAdapter.pas',
120-
HlpNullable in '..\..\HashLib\src\Nullable\HlpNullable.pas',
121120
HlpConverters in '..\..\HashLib\src\Utils\HlpConverters.pas',
122121
HlpBitConverter in '..\..\HashLib\src\Utils\HlpBitConverter.pas',
123122
HlpBits in '..\..\HashLib\src\Utils\HlpBits.pas',

HashLib/src/Hash128/HlpMurmurHash3_x64_128.pas

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ interface
88
HlpHashLibTypes,
99
HlpConverters,
1010
HlpIHashInfo,
11-
HlpNullable,
1211
HlpHash,
1312
HlpIHash,
1413
HlpHashResult,
@@ -45,7 +44,7 @@ TMurmurHash3_x64_128 = class sealed(THash, IHash128, IHashWithKey,
4544
C3 = UInt32($52DCE729);
4645
C4 = UInt32($38495AB5);
4746
{$ENDREGION}
48-
function GetKeyLength(): TNullableInteger;
47+
function GetKeyLength(): Int32;
4948
function GetKey: THashLibByteArray; inline;
5049
procedure SetKey(const AValue: THashLibByteArray); inline;
5150

@@ -56,7 +55,7 @@ TMurmurHash3_x64_128 = class sealed(THash, IHash128, IHashWithKey,
5655
AIndex, ALength: Int32); override;
5756
function TransformFinal: IHashResult; override;
5857
function Clone(): IHash; override;
59-
property KeyLength: TNullableInteger read GetKeyLength;
58+
property KeyLength: Int32 read GetKeyLength;
6059
property Key: THashLibByteArray read GetKey write SetKey;
6160
end;
6261

@@ -366,7 +365,7 @@ function TMurmurHash3_x64_128.GetKey: THashLibByteArray;
366365
result := TConverters.ReadUInt32AsBytesLE(FKey);
367366
end;
368367

369-
function TMurmurHash3_x64_128.GetKeyLength: TNullableInteger;
368+
function TMurmurHash3_x64_128.GetKeyLength: Int32;
370369
begin
371370
result := 4;
372371
end;
@@ -388,10 +387,10 @@ procedure TMurmurHash3_x64_128.SetKey(const AValue: THashLibByteArray);
388387
end
389388
else
390389
begin
391-
if System.length(AValue) <> KeyLength.value then
390+
if System.length(AValue) <> KeyLength then
392391
begin
393392
raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
394-
[KeyLength.value]);
393+
[KeyLength]);
395394
end;
396395
FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
397396
end;

HashLib/src/Hash128/HlpMurmurHash3_x86_128.pas

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ interface
88
HlpHashLibTypes,
99
HlpConverters,
1010
HlpIHashInfo,
11-
HlpNullable,
1211
HlpHash,
1312
HlpIHash,
1413
HlpHashResult,
@@ -50,7 +49,7 @@ TMurmurHash3_x86_128 = class sealed(THash, IHash128, IHashWithKey,
5049
C10 = UInt32($32AC3B17);
5150

5251
{$ENDREGION}
53-
function GetKeyLength(): TNullableInteger;
52+
function GetKeyLength(): Int32;
5453
function GetKey: THashLibByteArray; inline;
5554
procedure SetKey(const AValue: THashLibByteArray); inline;
5655

@@ -61,7 +60,7 @@ TMurmurHash3_x86_128 = class sealed(THash, IHash128, IHashWithKey,
6160
AIndex, ALength: Int32); override;
6261
function TransformFinal: IHashResult; override;
6362
function Clone(): IHash; override;
64-
property KeyLength: TNullableInteger read GetKeyLength;
63+
property KeyLength: Int32 read GetKeyLength;
6564
property Key: THashLibByteArray read GetKey write SetKey;
6665
end;
6766

@@ -425,7 +424,7 @@ function TMurmurHash3_x86_128.GetKey: THashLibByteArray;
425424
result := TConverters.ReadUInt32AsBytesLE(FKey);
426425
end;
427426

428-
function TMurmurHash3_x86_128.GetKeyLength: TNullableInteger;
427+
function TMurmurHash3_x86_128.GetKeyLength: Int32;
429428
begin
430429
result := 4;
431430
end;
@@ -449,10 +448,10 @@ procedure TMurmurHash3_x86_128.SetKey(const AValue: THashLibByteArray);
449448
end
450449
else
451450
begin
452-
if System.length(AValue) <> KeyLength.value then
451+
if System.length(AValue) <> KeyLength then
453452
begin
454453
raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
455-
[KeyLength.value]);
454+
[KeyLength]);
456455
end;
457456
FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
458457
end;

HashLib/src/Hash32/HlpMurmur2.pas

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ interface
1111
HlpIHashInfo,
1212
HlpHashResult,
1313
HlpIHashResult,
14-
HlpMultipleTransformNonBlock,
15-
HlpNullable;
14+
HlpMultipleTransformNonBlock;
1615

1716
resourcestring
1817
SInvalidKeyLength = 'KeyLength Must Be Equal to %d';
@@ -31,7 +30,7 @@ TMurmur2 = class sealed(TMultipleTransformNonBlock, IHash32, IHashWithKey,
3130
M = UInt32($5BD1E995);
3231
R = Int32(24);
3332

34-
function GetKeyLength(): TNullableInteger;
33+
function GetKeyLength(): Int32;
3534
function GetKey: THashLibByteArray; inline;
3635
procedure SetKey(const AValue: THashLibByteArray); inline;
3736

@@ -43,7 +42,7 @@ TMurmur2 = class sealed(TMultipleTransformNonBlock, IHash32, IHashWithKey,
4342
constructor Create();
4443
procedure Initialize(); override;
4544
function Clone(): IHash; override;
46-
property KeyLength: TNullableInteger read GetKeyLength;
45+
property KeyLength: Int32 read GetKeyLength;
4746
property Key: THashLibByteArray read GetKey write SetKey;
4847

4948
end;
@@ -71,16 +70,16 @@ procedure TMurmur2.SetKey(const AValue: THashLibByteArray);
7170
end
7271
else
7372
begin
74-
if System.Length(AValue) <> KeyLength.value then
73+
if System.Length(AValue) <> KeyLength then
7574
begin
7675
raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
77-
[KeyLength.value]);
76+
[KeyLength]);
7877
end;
7978
FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
8079
end;
8180
end;
8281

83-
function TMurmur2.GetKeyLength: TNullableInteger;
82+
function TMurmur2.GetKeyLength: Int32;
8483
begin
8584
result := 4;
8685
end;

HashLib/src/Hash32/HlpMurmurHash3_x86_32.pas

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ interface
88
HlpHashLibTypes,
99
HlpConverters,
1010
HlpIHashInfo,
11-
HlpNullable,
1211
HlpHash,
1312
HlpIHash,
1413
HlpHashResult,
@@ -41,7 +40,7 @@ TMurmurHash3_x86_32 = class sealed(THash, IHash32, IHashWithKey,
4140
C4 = UInt32($85EBCA6B);
4241
C5 = UInt32($C2B2AE35);
4342

44-
function GetKeyLength(): TNullableInteger;
43+
function GetKeyLength(): Int32;
4544
function GetKey: THashLibByteArray; inline;
4645
procedure SetKey(const AValue: THashLibByteArray); inline;
4746

@@ -52,7 +51,7 @@ TMurmurHash3_x86_32 = class sealed(THash, IHash32, IHashWithKey,
5251
AIndex, ALength: Int32); override;
5352
function TransformFinal: IHashResult; override;
5453
function Clone(): IHash; override;
55-
property KeyLength: TNullableInteger read GetKeyLength;
54+
property KeyLength: Int32 read GetKeyLength;
5655
property Key: THashLibByteArray read GetKey write SetKey;
5756

5857
end;
@@ -178,16 +177,16 @@ procedure TMurmurHash3_x86_32.SetKey(const AValue: THashLibByteArray);
178177
end
179178
else
180179
begin
181-
if System.Length(AValue) <> KeyLength.value then
180+
if System.Length(AValue) <> KeyLength then
182181
begin
183182
raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
184-
[KeyLength.value]);
183+
[KeyLength]);
185184
end;
186185
FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
187186
end;
188187
end;
189188

190-
function TMurmurHash3_x86_32.GetKeyLength: TNullableInteger;
189+
function TMurmurHash3_x86_32.GetKeyLength: Int32;
191190
begin
192191
result := 4;
193192
end;

HashLib/src/Hash32/HlpXXHash32.pas

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ interface
1212
HlpIHashInfo,
1313
HlpHashResult,
1414
HlpIHashResult,
15-
HlpNullable,
1615
HlpBits;
1716

1817
resourcestring
@@ -35,7 +34,7 @@ TXXHash32 = class sealed(THash, IHash32, IHashWithKey, ITransformBlock)
3534
PRIME32_4 = UInt32(668265263);
3635
PRIME32_5 = UInt32(374761393);
3736

38-
function GetKeyLength(): TNullableInteger;
37+
function GetKeyLength(): Int32;
3938
function GetKey: THashLibByteArray; inline;
4039
procedure SetKey(const AValue: THashLibByteArray); inline;
4140

@@ -64,7 +63,7 @@ TXXH_State = record
6463
AIndex, ALength: Int32); override;
6564
function TransformFinal(): IHashResult; override;
6665
function Clone(): IHash; override;
67-
property KeyLength: TNullableInteger read GetKeyLength;
66+
property KeyLength: Int32 read GetKeyLength;
6867
property Key: THashLibByteArray read GetKey write SetKey;
6968

7069
end;
@@ -111,7 +110,7 @@ function TXXHash32.GetKey: THashLibByteArray;
111110
result := TConverters.ReadUInt32AsBytesLE(FKey);
112111
end;
113112

114-
function TXXHash32.GetKeyLength: TNullableInteger;
113+
function TXXHash32.GetKeyLength: Int32;
115114
begin
116115
result := 4;
117116
end;
@@ -135,10 +134,10 @@ procedure TXXHash32.SetKey(const AValue: THashLibByteArray);
135134
end
136135
else
137136
begin
138-
if System.Length(AValue) <> KeyLength.value then
137+
if System.Length(AValue) <> KeyLength then
139138
begin
140139
raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
141-
[KeyLength.value]);
140+
[KeyLength]);
142141
end;
143142
FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
144143
end;

HashLib/src/Hash64/HlpMurmur2_64.pas

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ interface
1111
HlpIHashInfo,
1212
HlpHashResult,
1313
HlpIHashResult,
14-
HlpMultipleTransformNonBlock,
15-
HlpNullable;
14+
HlpMultipleTransformNonBlock;
1615

1716
resourcestring
1817
SInvalidKeyLength = 'KeyLength Must Be Equal to %d';
@@ -32,7 +31,7 @@ TMurmur2_64 = class sealed(TMultipleTransformNonBlock, IHash64, IHashWithKey,
3231
M: UInt64 = UInt64($C6A4A7935BD1E995);
3332
R = Int32(47);
3433

35-
function GetKeyLength(): TNullableInteger;
34+
function GetKeyLength(): Int32;
3635
function GetKey: THashLibByteArray; inline;
3736
procedure SetKey(const AValue: THashLibByteArray); inline;
3837

@@ -44,7 +43,7 @@ TMurmur2_64 = class sealed(TMultipleTransformNonBlock, IHash64, IHashWithKey,
4443
constructor Create();
4544
procedure Initialize(); override;
4645
function Clone(): IHash; override;
47-
property KeyLength: TNullableInteger read GetKeyLength;
46+
property KeyLength: Int32 read GetKeyLength;
4847
property Key: THashLibByteArray read GetKey write SetKey;
4948

5049
end;
@@ -214,7 +213,7 @@ function TMurmur2_64.GetKey: THashLibByteArray;
214213
result := TConverters.ReadUInt64AsBytesLE(FKey);
215214
end;
216215

217-
function TMurmur2_64.GetKeyLength: TNullableInteger;
216+
function TMurmur2_64.GetKeyLength: Int32;
218217
begin
219218
result := 8;
220219
end;
@@ -233,10 +232,10 @@ procedure TMurmur2_64.SetKey(const AValue: THashLibByteArray);
233232
end
234233
else
235234
begin
236-
if System.length(AValue) <> KeyLength.value then
235+
if System.length(AValue) <> KeyLength then
237236
begin
238237
raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
239-
[KeyLength.value]);
238+
[KeyLength]);
240239
end;
241240
FKey := TConverters.ReadBytesAsUInt64LE(PByte(AValue), 0);
242241
end;

0 commit comments

Comments
 (0)