Skip to content
Browse files

Performance optimization: faster IDE and Installer start

  • Loading branch information...
1 parent 694e34d commit 56762a72ed98e68baff78310caca727d06e7c5b6 @ahausladen ahausladen committed Dec 2, 2013
Showing with 40 additions and 2 deletions.
  1. +40 −2 jcl/source/common/JclIDEUtils.pas
View
42 jcl/source/common/JclIDEUtils.pas
@@ -3518,15 +3518,53 @@ class function TJclBDSInstallation.GetCommonProjectsDirectory(const RootDir: str
IDEVersionNumber: Integer): string;
var
Variables: TStrings;
+ I: Integer;
+ S, StartS: string;
+ ps: Integer;
+ LowerEnvVariableBDSCOMDIRValueName: string;
begin
if IDEVersionNumber >= 5 then
begin
Result := '';
Variables := TStringList.Create;
try
- GetRADStudioVars(RootDir, IDEVersionNumber, Variables);
- Result := Variables.Values[EnvVariableBDSCOMDIRValueName];
+ // Try to parse the rsvars.bat what is much faster than creating a cmd.exe process.
+ try
+ Variables.LoadFromFile(GetRADStudioVarsFileName(RootDir, IDEVersionNumber));
+ LowerEnvVariableBDSCOMDIRValueName := LowerCase(EnvVariableBDSCOMDIRValueName);
+ // Find "[@]SET BDSCOMMONDIR=..."
+ for I := Variables.Count - 1 downto 0 do // the last occurrence overwrites the others
+ begin
+ S := LowerCase(Variables[I]);
+ ps := Pos(LowerEnvVariableBDSCOMDIRValueName, S);
+ if ps > 0 then
+ begin
+ StartS := Trim(Copy(S, 1, ps - 1));
+ if (StartS <> '') and (StartS[1] = '@') then
+ StartS := Trim(Copy(StartS, 2, Length(StartS)));
+ if StartS = 'set' then
+ begin
+ S := Trim(Copy(Variables[I], ps + Length(EnvVariableBDSCOMDIRValueName), Length(Variables[I])));
+ if (S <> '') and (S[1] = '=') then
+ begin
+ S := Copy(S, 2, Length(S));
+ if Pos('%', S) = 0 then // if there is a macro in the string we fall back to using cmd.exe
+ Result := S;
+ Break;
+ end;
+ end;
+ end;
+ end;
+ except
+ Result := '';
+ end;
+
+ if Result = '' then
+ begin
+ GetRADStudioVars(RootDir, IDEVersionNumber, Variables);
+ Result := Variables.Values[EnvVariableBDSCOMDIRValueName];
+ end;
finally
Variables.Free;
end;

0 comments on commit 56762a7

Please sign in to comment.
Something went wrong with that request. Please try again.