@@ -459,8 +459,27 @@ procedure TOneBRC.ProcessData (aThreadNb: TThreadCount; aStartIdx: Int64; aEndId
459459 vLineStart := i;
460460
461461 while i < aEndIdx do begin
462- while FData[i] <> #10 do begin
463- Inc (I);
462+
463+ // can still skip some chars
464+ if FData[i] > ' ;' then begin
465+ Inc (I, 5 );
466+ end ;
467+
468+ // unroll a few seems to be improving?
469+ if FData[i] <> #10 then begin
470+ Inc (i);
471+ if FData[i] <> #10 then begin
472+ Inc (i);
473+ if FData[i] <> #10 then begin
474+ Inc (I);
475+ if FData[i] <> #10 then begin
476+ Inc (i);
477+ while FData[i] <> #10 do begin
478+ Inc (I);
479+ end ;
480+ end ;
481+ end ;
482+ end ;
464483 end ;
465484
466485 // new line parsed, process its contents
@@ -557,13 +576,11 @@ function MyFormatInt (const aIn: SmallInt): AnsiString; inline;
557576// ---------------------------------------------------
558577
559578procedure TOneBRC.GenerateOutput ;
560- var vMean: Integer;
561- vStream: TStringStream;
562- I, N: Int64;
579+ var vStream: TStringStream;
580+ I, N: Int32;
563581 vData: PStationData;
564582 vHash: Cardinal;
565583 vStations: TStringList;
566- iStationName: AnsiString;
567584 vIdx: THashSize;
568585 vRes: Boolean;
569586begin
@@ -573,10 +590,11 @@ procedure TOneBRC.GenerateOutput;
573590 vStations.UseLocale := False;
574591 try
575592 vStations.BeginUpdate;
576- for iStationName in FDictionary.FStationNames do begin
577- if iStationName <> ' ' then
578- vStations.Add(iStationName );
593+ for i := 0 to cNumStations - 1 do begin
594+ if FDictionary.FStationNames[i] <> ' ' then
595+ vStations.Add (FDictionary.FStationNames[i] );
579596 end ;
597+
580598 vStations.EndUpdate;
581599 vStations.CustomSort (@Compare);
582600
@@ -593,11 +611,9 @@ procedure TOneBRC.GenerateOutput;
593611 FDictionary.InternalFind (vHash, vRes, vIdx);
594612 vData := @FDictionary.FThreadData[0 ][FDictionary.FIndexes[vIdx]];
595613
596- vMean := RoundExInteger(vData^.Sum/vData^.Count/10 );
597-
598614 vStream.WriteString(
599615 vStations[i] + ' =' + MyFormatInt(vData^.Min)
600- + ' /' + MyFormatInt(vMean )
616+ + ' /' + MyFormatInt(RoundExInteger(vData^.Sum/vData^.Count/ 10 ) )
601617 + ' /' + MyFormatInt(vData^.Max) + ' , '
602618 );
603619 Inc(I);
@@ -622,7 +638,6 @@ procedure TOneBRC.GenerateOutput;
622638procedure TBRCThread.Execute ;
623639begin
624640 FProc (FThreadNb, FStart, FEnd);
625- Terminate;
626641end ;
627642
628643constructor TBRCThread.Create(aProc: TThreadProc; aThreadNb: TThreadCount; aStart: Int64; aEnd: Int64);
0 commit comments