Skip to content

Commit af56858

Browse files
committed
no iterator / interim vars
1 parent b7f6422 commit af56858

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

entries/ghatem-fpc/src/OneBRC.lpr

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -563,13 +563,11 @@ function MyFormatInt (const aIn: SmallInt): AnsiString; inline;
563563
//---------------------------------------------------
564564

565565
procedure TOneBRC.GenerateOutput;
566-
var vMean: Integer;
567-
vStream: TStringStream;
566+
var vStream: TStringStream;
568567
I, N: Int64;
569568
vData: PStationData;
570569
vHash: Cardinal;
571570
vStations: TStringList;
572-
iStationName: AnsiString;
573571
vIdx: THashSize;
574572
vRes: Boolean;
575573
begin
@@ -579,8 +577,8 @@ procedure TOneBRC.GenerateOutput;
579577
vStations.UseLocale := False;
580578
try
581579
vStations.BeginUpdate;
582-
for iStationName in FDictionary.FStationNames do begin
583-
vStations.Add(iStationName);
580+
for I := 0 to N - 1 do begin
581+
vStations.Add(FDictionary.FStationNames[I]);
584582
end;
585583
vStations.EndUpdate;
586584
vStations.CustomSort (@Compare);
@@ -598,11 +596,9 @@ procedure TOneBRC.GenerateOutput;
598596
FDictionary.InternalFind (vHash, vRes, vIdx);
599597
vData := @FDictionary.FThreadData[0][FDictionary.FIndexes[vIdx]];
600598

601-
vMean := RoundExInteger(vData^.Sum/vData^.Count/10);
602-
603599
vStream.WriteString(
604600
vStations[i] + '=' + MyFormatInt(vData^.Min)
605-
+ '/' + MyFormatInt(vMean)
601+
+ '/' + MyFormatInt(RoundExInteger(vData^.Sum/vData^.Count/10))
606602
+ '/' + MyFormatInt(vData^.Max) + ', '
607603
);
608604
Inc(I);

0 commit comments

Comments
 (0)