Skip to content

Commit ce0caf9

Browse files
removed unused identifiers, initialized variables, updated project
1 parent caf5f8b commit ce0caf9

File tree

3 files changed

+88
-15
lines changed

3 files changed

+88
-15
lines changed

generator/Common/generate.common.pas

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ TGenerator = class(TObject)
2727
function GenerateProgressBar(APBPosition, APBMax, APBWIdth: Integer;
2828
AFileSize: Int64; ATimeElapsed: TDateTime): String;
2929
function Rng1brc(Range: Integer): Integer;
30-
protected
3130
public
3231
constructor Create(AInputFile, AOutputFile: String; ALineCount: Int64);
3332
destructor Destroy; override;
3433

3534
procedure Generate;
36-
published
3735
end;
3836

3937
{$IFNDEF FPC}

generator/Delphi/src/generator.dpr

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ type
3131
{ TOneBRCGenerator }
3232

3333
procedure TOneBRCGenerator.Run;
34-
var
35-
ErrorMsg: String;
3634
begin
3735
if ParseConsoleParams then
3836
begin
@@ -64,6 +62,8 @@ function TOneBRCGenerator.CheckLongParams(const AParam: string): Boolean;
6462
var
6563
J: Integer;
6664
begin
65+
Result := False;
66+
6767
for J := 0 to Pred(Length(cLongOptions)) do
6868
begin
6969
if (AParam = cLongOptions[J]) then
@@ -78,6 +78,8 @@ function TOneBRCGenerator.CheckShortParams(const AParam: char): Boolean;
7878
var
7979
J: Integer;
8080
begin
81+
Result := False;
82+
8183
for J := 0 to Pred(Length(cShortOptions)) do
8284
begin
8385
if (AParam = cShortOptions[J]) then
@@ -102,7 +104,9 @@ var
102104
ParamOK: Boolean;
103105
SkipNext: Boolean;
104106
begin
105-
Result := false;
107+
valid := 0;
108+
invalid := 0;
109+
106110
// initialize the params list
107111
if not Assigned(FParams) then
108112
FParams := TStringList.Create(dupIgnore, false, false);
@@ -130,6 +134,7 @@ begin
130134
// check for invalid input
131135
if FParams.Count > 0 then
132136
begin
137+
ParamOK := True;
133138
SkipNext := False;
134139
for I := 0 to FParams.Count - 1 do
135140
begin
@@ -168,18 +173,15 @@ begin
168173
if (FParams.Find(cShortOptHelp, J) or FParams.Find(cLongOptHelp, J)) then
169174
begin
170175
WriteHelp;
171-
inc(invalid);
172176
end;
173177

174178
// check version
175179
if (FParams.Find(cShortOptVersion, J) or FParams.Find(cLongOptVersion, J)) then
176180
begin
177181
WriteLn(Format(rsGeneratorVersion, [cVersion]));
178-
inc(invalid);
179182
end;
180183

181184
// check inputfilename
182-
J := -1;
183185
J := FParams.IndexOfName(cShortOptInput);
184186
if J = -1 then
185187
J := FParams.IndexOfName(cLongOptInput);
@@ -195,7 +197,6 @@ begin
195197
end;
196198

197199
// check outputfilename
198-
J := -1;
199200
J := FParams.IndexOfName(cShortOptOutput);
200201
if J = -1 then
201202
J := FParams.IndexOfName(cLongOptOutput);
@@ -211,7 +212,6 @@ begin
211212
end;
212213

213214
// check linecount
214-
J := -1;
215215
J := FParams.IndexOfName(cShortOptNumber);
216216
if J = -1 then
217217
J := FParams.IndexOfName(cLongOptNumber);
@@ -239,7 +239,7 @@ begin
239239
end;
240240

241241
// check if everything was provided
242-
Result := valid = 3;
242+
Result := (valid = 3) and (invalid = 0);
243243
end;
244244

245245
var
@@ -250,4 +250,8 @@ begin
250250
Application.Run;
251251
Application.Free;
252252

253+
{$IFDEF DEBUG}
254+
Writeln('Press ENTER...');
255+
Readln;
256+
{$ENDIF}
253257
end.

0 commit comments

Comments
 (0)