save a few cycles

This commit is contained in:
Basile Burg 2019-02-03 15:12:21 +01:00
parent 511bf285aa
commit a4e8358b82
1 changed files with 33 additions and 32 deletions

View File

@ -243,6 +243,7 @@ var
fls: string = ''; fls: string = '';
fle: string; fle: string;
lne: string; lne: string;
cnt: integer;
i: integer; i: integer;
begin begin
fModules.Clear; fModules.Clear;
@ -253,13 +254,14 @@ begin
prj := loadProject(fLibProject, true); prj := loadProject(fLibProject, true);
str := TStringList.Create; str := TStringList.Create;
try try
for i:= 0 to prj.sourcesCount-1 do cnt := prj.sourcesCount-1;
for i:= 0 to cnt do
begin begin
fle := prj.sourceAbsolute(i); fle := prj.sourceAbsolute(i);
if not hasDlangSyntax(fle.extractFileExt) then if not hasDlangSyntax(fle.extractFileExt) then
continue; continue;
fls += fle; fls += fle;
if i <> prj.sourcesCount-1 then if i <> cnt then
fls += PathSeparator; fls += PathSeparator;
end; end;
getModulesImports(fls, str); getModulesImports(fls, str);
@ -287,13 +289,14 @@ begin
str := TStringList.Create; str := TStringList.Create;
try try
listFiles(str, fLibSourcePath, true); listFiles(str, fLibSourcePath, true);
for i:= 0 to str.Count-1 do cnt := str.Count-1;
for i:= 0 to cnt do
begin begin
fle := str[i]; fle := str[i];
if not hasDlangSyntax(fle.extractFileExt) then if not hasDlangSyntax(fle.extractFileExt) then
continue; continue;
fls += fle; fls += fle;
if i <> str.Count-1 then if i <> cnt then
fls += PathSeparator; fls += PathSeparator;
end; end;
str.Clear; str.Clear;
@ -351,7 +354,6 @@ end;
destructor TLibraryManager.destroy; destructor TLibraryManager.destroy;
begin begin
ForceDirectoriesUTF8(getDocPath);
LibMan.saveToFile(getDocPath + libFname); LibMan.saveToFile(getDocPath + libFname);
fItemsByAlias.Free; fItemsByAlias.Free;
fCollection.Free; fCollection.Free;
@ -377,20 +379,21 @@ procedure TLibraryManager.FPOObservedChanged(ASender: TObject; Operation:
TFPObservedOperation; Data: Pointer); TFPObservedOperation; Data: Pointer);
var var
i,j: integer; i,j: integer;
obj: TObject;
lib: TLibraryItem; lib: TLibraryItem;
cli: TLibraryItem; cli: TLibraryItem;
dep: TLibraryItem; dep: TLibraryItem;
begin begin
if data.isNil then if data.isNil then
exit; exit;
obj := TObject(data);
if not (obj is TLibraryItem) then if operation <> ooDeleteItem then
exit;
if not (TObject(data) is TLibraryItem) then
exit; exit;
lib := TLibraryItem(data); lib := TLibraryItem(data);
case operation of if not fItemsByAlias.contains(lib.libAlias) then
ooDeleteItem: if fItemsByAlias.contains(lib.libAlias) then exit;
begin
for i:= 0 to lib.dependencies.Count-1 do for i:= 0 to lib.dependencies.Count-1 do
begin begin
dep := libraryByAlias[lib.dependencies[i]]; dep := libraryByAlias[lib.dependencies[i]];
@ -413,8 +416,6 @@ begin
end; end;
DCDWrapper.remImportFolder(lib.libSourcePath); DCDWrapper.remImportFolder(lib.libSourcePath);
fItemsByAlias.delete(lib.libAlias); fItemsByAlias.delete(lib.libAlias);
end;
end;
end; end;
procedure TLibraryManager.updateAfterAddition(lib: TLibraryItem); procedure TLibraryManager.updateAfterAddition(lib: TLibraryItem);