@@ -17,6 +17,7 @@ interface
1717
1818 TGenerator = class (TObject)
1919 private
20+ rndState: Array [0 ..1 ] of Cardinal;
2021 FInputFile: String;
2122 FOutPutFile: String;
2223 FLineCount: Int64;
@@ -52,7 +53,7 @@ implementation
5253;
5354
5455const
55- cSeed: LongInt = 46668267 ; // '1BRC' in ASCII
56+ cSeed = 46668267 ; // '1BRC' in ASCII
5657 linesPercent = 10 ;
5758 stationsCapacity = 50000 ;
5859 chunkBatch = 10000 ;
@@ -160,17 +161,15 @@ function TGenerator.GenerateProgressBar(APBPosition, APBMax, APBWIdth, AFileSize
160161end ;
161162
162163function TGenerator.Rng1brc (Range: longint): longint;
163- const
164- state: Array [0 ..1 ] of DWord = (46668267 , 7266 );
165164var
166- s0, s1, s2: DWord ;
165+ s0, s1, s2: Cardinal ;
167166begin
168- s0 := state [0 ];
169- s1 := state [1 ] xor s0;
170- s2 := RolDWord( s1 * 3 , 5 ) * 7 ;
167+ s0 := rndState [0 ];
168+ s1 := rndState [1 ] xor s0;
169+ s2 := (( s1 * 3 ) xor 5 ) * 7 ;
171170 Result := longint(Int64(s2 * range) shr 32 );
172- state [0 ] := s2;
173- state [1 ] := s0 xor (s1 shl 9 );
171+ rndState [0 ] := s2;
172+ rndState [1 ] := s0 xor (s1 shl 9 );
174173end ;
175174
176175procedure TGenerator.Generate ;
@@ -186,10 +185,9 @@ procedure TGenerator.Generate;
186185 chunkCount, chunkLen, stationsCount, temperaturesCount: Integer;
187186 start: TDateTime;
188187begin
189- // Randomize sets this variable depending on the current time
190- // We just set it to our own value
191- RandSeed := cSeed;
192-
188+ // random init
189+ rndState[0 ] := cSeed;
190+ rndState[1 ] := 7266 ;
193191 // Build list of station names
194192 BuildStationNames;
195193
0 commit comments