@@ -6,7 +6,7 @@ interface
66
77uses
88 Classes, SysUtils, Generics.Collections,
9- mormot.core.os;
9+ mormot.core.os, mormot.core.base ;
1010
1111function RoundExDouble (const ATemp: Double): Double; inline;
1212
@@ -97,6 +97,7 @@ implementation
9797uses
9898 CRC;
9999
100+
100101const
101102 c0ascii: ShortInt = 48 ;
102103 c9ascii: ShortInt = 57 ;
@@ -331,7 +332,8 @@ procedure TOneBRC.ProcessData (aThreadNb: UInt16; aStartIdx: Int64; aEndIdx: Int
331332 ExtractLineData (vLineStart, i - 1 , vLenStationName, vTemp);
332333
333334 // compute the hash starting at the station's first char, and its length
334- vHash := crc32(0 , @FData[vLineStart], vLenStationName);
335+ // mORMot's crc32c is ~33% faster than the built-in one
336+ vHash := crc32c(0 , @FData[vLineStart], vLenStationName);
335337
336338 if FstationsDicts[aThreadNb].TryGetValue(vHash, vData) then begin
337339 if vTemp < vData^.Min then
@@ -434,7 +436,7 @@ procedure TOneBRC.GenerateOutput;
434436 // the stations are now sorted, but we need to locate the data: recompute hash
435437 // would it be more efficient to store the hash as well?
436438 // debatable, and the whole output generation is < 0.3 seconds, so not exactly worth it
437- vHash := crc32 (0 , @vStations[i][1 ], Length (vStations[i]));
439+ vHash := crc32c (0 , @vStations[i][1 ], Length (vStations[i]));
438440 FStationsDicts[0 ].TryGetValue(vHash, vData);
439441 vMin := vData^.Min/10 ;
440442 vMax := vData^.Max/10 ;
0 commit comments