@@ -18,7 +18,6 @@ interface
1818 SbpStreamUtilities,
1919 SbpCodingAlphabet,
2020 SbpBitOperations,
21- SbpPlatformUtilities,
2221 SbpBinaryPrimitives;
2322
2423type
@@ -39,7 +38,6 @@ TBase32 = class(TInterfacedObject, IBase32, IBaseStreamCoder, INonAllocatingBa
3938
4039 var
4140 FAlphabet: IBase32Alphabet;
42- FIsBigEndian: Boolean;
4341
4442 class var FCrockford: IBase32;
4543 class var FRfc4648: IBase32;
@@ -77,8 +75,7 @@ TBase32 = class(TInterfacedObject, IBase32, IBaseStreamCoder, INonAllocatingBa
7775 public
7876 class constructor Create;
7977
80- constructor Create(const AAlphabet: IBase32Alphabet); overload;
81- constructor Create(const AAlphabet: IBase32Alphabet; AIsBigEndian: Boolean); overload;
78+ constructor Create(const AAlphabet: IBase32Alphabet);
8279
8380 class property Crockford: IBase32 read GetCrockford;
8481 class property Rfc4648: IBase32 read GetRfc4648;
@@ -139,11 +136,6 @@ implementation
139136end ;
140137
141138constructor TBase32.Create(const AAlphabet: IBase32Alphabet);
142- begin
143- Create(AAlphabet, not TPlatformUtilities.IsLittleEndian);
144- end ;
145-
146- constructor TBase32.Create(const AAlphabet: IBase32Alphabet; AIsBigEndian: Boolean);
147139begin
148140 inherited Create;
149141 if AAlphabet.PaddingPosition <> TPaddingPosition.&End then
@@ -153,7 +145,6 @@ constructor TBase32.Create(const AAlphabet: IBase32Alphabet; AIsBigEndian: Boole
153145 end ;
154146
155147 FAlphabet := AAlphabet;
156- FIsBigEndian := AIsBigEndian;
157148end ;
158149
159150function TBase32.GetAlphabet : IBase32Alphabet;
@@ -327,9 +318,8 @@ function TBase32.EncodeUInt64(const ANumber: UInt64): String;
327318const
328319 NumBytes = 8 ;
329320var
330- LBuffer, LSpan : TSimpleBaseLibByteArray;
321+ LBuffer: TSimpleBaseLibByteArray;
331322 LI: Int32;
332- LTmp: Byte;
333323begin
334324 if ANumber = 0 then
335325 begin
@@ -340,24 +330,6 @@ function TBase32.EncodeUInt64(const ANumber: UInt64): String;
340330 System.SetLength(LBuffer, NumBytes);
341331 TBinaryPrimitives.WriteUInt64LittleEndian(LBuffer, 0 , ANumber);
342332
343- if FIsBigEndian then
344- begin
345- LI := 0 ;
346- while (LI < NumBytes) and (LBuffer[LI] = 0 ) do
347- begin
348- Inc(LI);
349- end ;
350- LSpan := System.Copy(LBuffer, LI, NumBytes - LI);
351- for LI := 0 to (System.Length(LSpan) div 2 ) - 1 do
352- begin
353- LTmp := LSpan[LI];
354- LSpan[LI] := LSpan[System.Length(LSpan) - 1 - LI];
355- LSpan[System.Length(LSpan) - 1 - LI] := LTmp;
356- end ;
357- Result := Encode(LSpan);
358- Exit;
359- end ;
360-
361333 LI := NumBytes - 1 ;
362334 while (LI > 0 ) and (LBuffer[LI] = 0 ) do
363335 begin
@@ -369,8 +341,6 @@ function TBase32.EncodeUInt64(const ANumber: UInt64): String;
369341function TBase32.DecodeUInt64 (const AText: String): UInt64;
370342var
371343 LBuffer, LNewSpan: TSimpleBaseLibByteArray;
372- LI: Int32;
373- LTmp: Byte;
374344begin
375345 LBuffer := Decode(AText);
376346 if System.Length(LBuffer) = 0 then
@@ -388,24 +358,13 @@ function TBase32.DecodeUInt64(const AText: String): UInt64;
388358 TArrayUtilities.Fill<Byte>(LNewSpan, 0 , 8 , Byte(0 ));
389359 Move(LBuffer[0 ], LNewSpan[0 ], System.Length(LBuffer));
390360
391- if FIsBigEndian then
392- begin
393- for LI := 0 to 3 do
394- begin
395- LTmp := LNewSpan[LI];
396- LNewSpan[LI] := LNewSpan[7 - LI];
397- LNewSpan[7 - LI] := LTmp;
398- end ;
399- end ;
400-
401361 Result := TBinaryPrimitives.ReadUInt64LittleEndian(LNewSpan, 0 );
402362end ;
403363
404364function TBase32.TryDecodeUInt64 (const AText: String; out ANumber: UInt64): Boolean;
405365var
406366 LOutput: TSimpleBaseLibByteArray;
407- LBytesWritten, LI: Int32;
408- LTmp: Byte;
367+ LBytesWritten: Int32;
409368begin
410369 System.SetLength(LOutput, 8 );
411370 TArrayUtilities.Fill<Byte>(LOutput, 0 , 8 , Byte(0 ));
@@ -416,16 +375,6 @@ function TBase32.TryDecodeUInt64(const AText: String; out ANumber: UInt64): Bool
416375 Exit;
417376 end ;
418377
419- if FIsBigEndian then
420- begin
421- for LI := 0 to 3 do
422- begin
423- LTmp := LOutput[LI];
424- LOutput[LI] := LOutput[7 - LI];
425- LOutput[7 - LI] := LTmp;
426- end ;
427- end ;
428-
429378 ANumber := TBinaryPrimitives.ReadUInt64LittleEndian(LOutput, 0 );
430379 Result := True;
431380end ;
0 commit comments