Skip to content

Commit 5f526ca

Browse files
committed
Improve locality in ResolveUnitReferences
1 parent d332250 commit 5f526ca

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

Source/dwsCompiler.pas

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,6 @@ destructor TdwsCompiler.Destroy;
12591259

12601260
function TdwsCompiler.ResolveUnitReferences(scriptType : TScriptSourceType) : TIdwsUnitList;
12611261
var
1262-
i, j, k : Integer;
12631262
expectedUnitCount : Integer;
12641263
deps : TStringList;
12651264
refCount : array of Integer;
@@ -1277,20 +1276,20 @@ function TdwsCompiler.ResolveUnitReferences(scriptType : TScriptSourceType) : TI
12771276
SetLength(refCount, expectedUnitCount);
12781277

12791278
// Calculate number of outgoing references
1280-
for i:=0 to FCompilerContext.UnitList.Count-1 do begin
1279+
for var i := 0 to FCompilerContext.UnitList.Count-1 do begin
12811280
curUnit := FCompilerContext.UnitList[i];
12821281
if (ufImplicitUse in curUnit.GetUnitFlags)
12831282
or ( (scriptType<>stUnit)
12841283
and not (coExplicitUnitUses in FOptions)) then begin
12851284
deps := curUnit.GetDependencies;
1286-
for j:=0 to deps.Count-1 do begin
1285+
for var j := 0 to deps.Count-1 do begin
12871286
if FCompilerContext.UnitList.IndexOfName(deps[j])<0 then
12881287
FMsgs.AddCompilerStopFmt(cNullPos, CPE_UnitNotFound,
12891288
[deps[j], curUnit.GetUnitName]);
12901289
end;
1291-
refCount[i]:=deps.Count;
1290+
refCount[i] := deps.Count;
12921291
end else begin
1293-
refCount[i]:=-1;
1292+
refCount[i] := -1;
12941293
Dec(expectedUnitCount);
12951294
end;
12961295
end;
@@ -1300,17 +1299,17 @@ function TdwsCompiler.ResolveUnitReferences(scriptType : TScriptSourceType) : TI
13001299
// Resolve references
13011300
repeat
13021301
changed:=False;
1303-
for i:=0 to FCompilerContext.UnitList.Count-1 do begin
1302+
for var i := 0 to FCompilerContext.UnitList.Count-1 do begin
13041303
// Find unit that is not referencing other units
13051304
if refCount[i]=0 then begin
13061305
curUnit := FCompilerContext.UnitList[i];
13071306
Result.Add(curUnit);
13081307

13091308
// Remove the references to this unit from all other units
13101309
unitName:=curUnit.GetUnitName;
1311-
for j:=0 to FCompilerContext.UnitList.Count-1 do begin
1310+
for var j := 0 to FCompilerContext.UnitList.Count-1 do begin
13121311
deps := FCompilerContext.UnitList[j].GetDependencies;
1313-
for k:=0 to deps.Count-1 do begin
1312+
for var k := 0 to deps.Count-1 do begin
13141313
if UnicodeSameText(deps[k], unitName) then
13151314
Dec(refCount[j]);
13161315
end;

0 commit comments

Comments
 (0)