55interface
66
77uses
8- Classes, SysUtils, Generics.Collections,
8+ Classes, SysUtils,
99 mormot.core.os, mormot.core.base;
1010
1111function RoundExDouble (const ATemp: Double): Double; inline;
@@ -25,18 +25,17 @@ function RoundExDouble(const ATemp: Double): Double; inline;
2525 Name : AnsiString;
2626 end ;
2727 PStationData = ^TStationData;
28- TStationsDict = specialize TDictionary<Cardinal, PStationData>;
2928
30- TKeys = array of Cardinal;
31- TValues = array of PStationData;
29+ TKeys = array [ 0 .. 45006 ] of Cardinal;
30+ TValues = array [ 0 .. 45006 ] of PStationData;
3231
3332 { TMyDictionary }
3433
3534 TMyDictionary = class
3635 private
3736 FHashes: TKeys;
3837 FValues: TValues;
39- FRecords: array of TStationData;
38+ FRecords: array [ 0 .. 45006 ] of TStationData;
4039 procedure InternalFind (const aKey: Cardinal; out aFound: Boolean; out aIndex: Integer);
4140 public
4241 constructor Create;
@@ -128,27 +127,11 @@ function Compare(AList: TStringList; AIndex1, AIndex2: Integer): Integer;
128127
129128{ TMyDictionary }
130129
131- const
132- cHashConst: Double = (Sqrt(5 ) - 1 ) / 2 ;
133-
134130procedure TMyDictionary.InternalFind (const aKey: Cardinal; out aFound: Boolean; out aIndex: Integer);
135131var vIdx: Integer;
136- vDbl: Double;
137132 vOffset: Integer;
138133begin
139- { $IFDEF HASHMULT}
140- vDbl := aKey * cHashConst;
141- vDbl := vDbl - Trunc (vDbl);
142- vIdx := Trunc (vDbl * cDictSize);
143- { $ENDIF}
144- { $IFDEF LEMIRE}
145134 vIdx := aKey * cDictSize shr 32 ;
146- { $ENDIF}
147- { $IFDEF HASHMOD}
148- vIdx := aKey mod cDictSize;
149- { $ENDIF}
150-
151- aFound := False;
152135
153136 if FHashes[vIdx] = aKey then begin
154137 aIndex := vIdx;
@@ -170,8 +153,8 @@ procedure TMyDictionary.InternalFind(const aKey: Cardinal; out aFound: Boolean;
170153 aIndex := vIdx;
171154 aFound := True;
172155 break;
173- end
174- else if FHashes[vIdx] = 0 then begin
156+ end ;
157+ if FHashes[vIdx] = 0 then begin
175158 // found empty bucket to use
176159 aIndex := vIdx;
177160 aFound := False;
@@ -185,10 +168,6 @@ constructor TMyDictionary.Create;
185168var
186169 I: Integer;
187170begin
188- SetLength (FHashes, cDictSize);
189- SetLength (FValues, cDictSize);
190- SetLength (FRecords, cDictSize);
191-
192171 for I := 0 to cDictSize - 1 do begin
193172 FValues[I] := @FRecords[I];
194173 end ;
0 commit comments