@@ -417,50 +417,49 @@ procedure TOneBRC.ProcessData (aThreadNb: TThreadCount; aStartIdx: Int64; aEndId
417417 vLineStart := i;
418418
419419 while i < aEndIdx do begin
420- if FData[i] = #10 then begin
421- // new line parsed, process its contents
422- ExtractLineData (vLineStart, i - 1 , vLenStationName, vTemp) ;
423-
424- // compute the hash starting at the station's first char, and its length
425- // mORMot's crc32c is ~33% faster than the built-in one
426- vHash := crc32c( 0 , @FData[vLineStart], vLenStationName);
427-
428- FDictionary.InternalFind (vHash, vFound, vHashIdx);
429-
430-
431- if vFound then begin
432- vData := @FDictionary.FThreadData[aThreadNb][FDictionary.FIndexes[vHashIdx]];
433- if vTemp < vData^.Min then
434- vData^.Min := vTemp;
435- if vTemp > vData^.Max then
436- vData^.Max := vTemp;
437- Inc ( vData^.Sum, vTemp) ;
438- Inc ( vData^.Count);
439- end
440- else begin
441- // pre-allocated array of records instead of on-the-go allocation
442- vHashIdx := FDictionary.AtomicRegisterHash (vHash);
443- // SetString done only once per station name, for later sorting
444- SetString(vStation, pAnsiChar(@FData[vLineStart]), vLenStationName);
445-
446- FDictionary.Add(vHashIdx, aThreadNb, vTemp, vStation);
447- end ;
420+ while FData[i] <> #10 do begin
421+ Inc (I);
422+ end ;
423+
424+ // new line parsed, process its contents
425+ ExtractLineData (vLineStart, i - 1 , vLenStationName, vTemp);
426+
427+ // compute the hash starting at the station's first char, and its length
428+ // mORMot's crc32c is ~33% faster than the built-in one
429+ vHash := crc32c( 0 , @FData[vLineStart], vLenStationName);
430+
431+ FDictionary.InternalFind (vHash, vFound, vHashIdx);
432+
433+
434+ if vFound then begin
435+ vData := @FDictionary.FThreadData[aThreadNb][FDictionary.FIndexes[vHashIdx]];
436+ if vTemp < vData^.Min then
437+ vData^.Min := vTemp;
438+ if vTemp > vData^.Max then
439+ vData^.Max := vTemp;
440+ Inc (vData^.Sum, vTemp);
441+ Inc (vData^.Count);
442+ end
443+ else begin
444+ // pre-allocated array of records instead of on-the-go allocation
445+ vHashIdx := FDictionary.AtomicRegisterHash (vHash);
446+ // SetString done only once per station name, for later sorting
447+ SetString(vStation, pAnsiChar(@FData[vLineStart]), vLenStationName) ;
448448
449- // we're at a #10: next line starts at the next index
450- vLineStart := i+1 ;
451-
452- // we're at a #10:
453- // until the next #10 char, there will be:
454- // - 1 semicolon
455- // - 3 chars for the temp (min)
456- // - 2 chars for the name (min)
457- // - the usual Inc (I)
458- // so we should be able to skip 7 chars until another #10 may appear
459- Inc (i, 7 );
460- continue;
449+ FDictionary.Add(vHashIdx, aThreadNb, vTemp, vStation);
461450 end ;
462451
463- Inc (i);
452+ // we're at a #10: next line starts at the next index
453+ vLineStart := i+1 ;
454+
455+ // we're at a #10:
456+ // until the next #10 char, there will be:
457+ // - 1 semicolon
458+ // - 3 chars for the temp (min)
459+ // - 2 chars for the name (min)
460+ // - the usual Inc (I)
461+ // so we should be able to skip 7 chars until another #10 may appear
462+ Inc (i, 7 );
464463 end ;
465464end ;
466465
0 commit comments