Wednesday, October 24, 2007

Improve the loading speed of Delphi application built with runtime package

I just come across with the article The ultimate Delphi IDE start-up hack When we use SysUtils.LoadPackage in Delphi, the following procedure will be invoked:
procedure InitializePackage(Module: HMODULE; AValidatePackage: TValidatePackageProc);
type
 TPackageLoad = procedure;
var
 PackageLoad: TPackageLoad;
begin
 CheckForDuplicateUnits(Module, AValidatePackage);
 @PackageLoad := GetProcAddress(Module, 'Initialize'); //Do not localize
 if Assigned(PackageLoad) then
   PackageLoad
 else
   raise EPackageError.CreateFmt(sInvalidPackageFile, [GetModuleName(Module)]);
end;
If we are very sure that our .bpl packages has no duplicate unit name, we may safely ignore the call to "CheckForDuplicateUnits" procedure. It should improve the loading speed of your Delphi application that built with runtime packages.

No comments: