Skip to content

Commit c5a3769

Browse files
committed
static arrays are faster?
1 parent e89625a commit c5a3769

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

entries/ghatem-fpc/src/onebrc.pas

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ function RoundExDouble(const ATemp: Double): Double; inline;
2626
end;
2727
PStationData = ^TStationData;
2828

29-
TKeys = array of Cardinal;
30-
TValues = array of PStationData;
29+
TKeys = array [0..45007] of Cardinal;
30+
TValues = array [0..45007] of PStationData;
3131

3232
{ TMyDictionary }
3333

3434
TMyDictionary = class
3535
private
3636
FHashes: TKeys;
3737
FValues: TValues;
38-
FRecords: array of TStationData;
38+
FRecords: array [0..45007] of TStationData;
3939
procedure InternalFind(const aKey: Cardinal; out aFound: Boolean; out aIndex: Integer);
4040
public
4141
constructor Create;
@@ -168,10 +168,6 @@ constructor TMyDictionary.Create;
168168
var
169169
I: Integer;
170170
begin
171-
SetLength (FHashes, cDictSize);
172-
SetLength (FValues, cDictSize);
173-
SetLength (FRecords, cDictSize);
174-
175171
for I := 0 to cDictSize - 1 do begin
176172
FValues[I] := @FRecords[I];
177173
end;

0 commit comments

Comments
 (0)