Skip to content

Commit f1adc1b

Browse files
committed
Update - Minor edits.
1 parent 29ba3af commit f1adc1b

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

entries/ikelaiah/src/weatherstation.pas

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ procedure TWeatherStation.SortWeatherStationAndStats;
199199
{$ENDIF DEBUG}
200200
end;
201201

202-
procedure TWeatherStation.AddCityTemperatureLG(const cityName: string;
203-
const newTemp: int64);
202+
procedure TWeatherStation.AddCityTemperatureLG(const cityName: string; const newTemp: int64);
204203
var
205204
stat: PStat;
206205
begin
@@ -211,21 +210,17 @@ procedure TWeatherStation.AddCityTemperatureLG(const cityName: string;
211210
stat := self.weatherDictionary[cityName];
212211

213212
// If the temp lower then min, set the new min.
214-
if newTemp < stat^.min then
215-
stat^.min := newTemp;
213+
if newTemp < stat^.min then stat^.min := newTemp;
216214

217215
// If the temp higher than max, set the new max.
218-
if newTemp > stat^.max then
219-
stat^.max := newTemp;
216+
if newTemp > stat^.max then stat^.max := newTemp;
220217

221218
// Add count for this city.
222219
stat^.sum := stat^.sum + newTemp;
223220

224221
// Increase the counter
225222
stat^.cnt := stat^.cnt + 1;
226223

227-
// Update the stat of this city
228-
// self.weatherDictionary.AddOrSetValue(cityName, stat);
229224
{$IFDEF DEBUG}
230225
// Display the line.
231226
WriteLn('Updated: ', cityName);
@@ -370,35 +365,28 @@ procedure TWeatherStation.ParseStationAndTempFromChunk(const chunkData: pansicha
370365
const dataSize: int64; const chunkIndex: int64);
371366
var
372367
index, lineStart, lineLength: int64;
373-
batch: TStringList;
368+
line:string;
369+
374370
begin
375371
lineStart := 0;
376-
batch := TStringList.Create;
377-
try
372+
378373
// Check for Line Feed (LF)
379374
for index := 0 to dataSize - 1 do
380375
begin
381376
if chunkData[index] = #10 then
382377
begin
383-
384378
lineLength := index - lineStart;
385-
386379
// Remove potential CR before LF (for Windows)
387380
if (chunkData[index - 1] = #13) and (index < dataSize - 1) then
388381
Dec(LineLength);
389382

390383
// The current line is now: Buffer[LineStart..LineStart+LineLength-1]
391-
// WriteLn(chunkData[lineStart..lineStart + lineLength - 1], '.');
384+
// To print: WriteLn(chunkData[lineStart..lineStart + lineLength - 1], '.');
392385
self.ParseStationAndTemp(chunkData[lineStart..lineStart + lineLength - 1]);
393386
// Skip to the next 'line' in the buffer
394387
lineStart := index + 1;
395388
end;
396389
end;
397-
398-
finally
399-
batch.Free;
400-
end;
401-
402390
end;
403391

404392
procedure TWeatherStation.ReadMeasurementsInChunks(const filename: string);
@@ -478,7 +466,6 @@ procedure TWeatherStation.ProcessMeasurements;
478466
// self.ReadMeasurementsClassic;
479467
{chunking cuts ~ 30 - 40 seconds of processing time from ~6.45 to 6.00}
480468
self.ReadMeasurementsInChunks(self.fname);
481-
482469
self.SortWeatherStationAndStats;
483470
self.PrintSortedWeatherStationAndStats;
484471
end;

0 commit comments

Comments
 (0)