View Issue Details

IDProjectCategoryView StatusLast Update
0005980JEDI VCL02 Installationpublic2015-09-21 17:47
ReporterAriochAssigned ToAHUser 
PrioritynormalSeveritytrivialReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version3.49 
Summary0005980: redundant loop body
DescriptionD:\DelphiProjects\Libs\JediVCL\jvcl\install\JVCLInstall\Utils.pas

procedure AddPaths(List: TStrings; Add: Boolean; const Dir: string;
  const Paths: array of string);


1st loop is re-calculating Path local var when it did not changed.


Additionally, either to use hardcoded '\' or x-platform PathDelim;
Steps To ReproduceCurrent code:

  for j := 0 to High(Paths) do
    for i := List.Count - 1 downto 0 do
      if Paths[j] <> '' then
      begin
        Path := Paths[j];
        if (Pos(':', Path) = 0) and (Path[1] <> '$') then
          Path := PathDelim + ExtractFileName(Dir) + PathDelim + Paths[j];
        if EndsWith(List[i], Path, True) then
          List.Delete(i)
        else if EndsWith(List[i], Path + '\', True) then
          List.Delete(i);
      end;
Additional InformationBetter code :

  for j := 0 to High(Paths) do begin
    Path := Paths[j];
    if Path <> '' then
    begin
      if (Pos(':', Path) = 0) and (Path[1] <> '$') then
        Path := PathDelim + ExtractFileName(Dir) + PathDelim + Paths[j];
      for i := List.Count - 1 downto 0 do begin
          if EndsWith(List[i], Path, True) then
            List.Delete(i)
          else if EndsWith(List[i], Path + PathDelim, True) then
            List.Delete(i);
      end;
     end;
    end;
TagsNo tags attached.

Activities

obones

2013-01-15 15:29

administrator   ~0020357

Please check with latest SVN content, Andreas may have changed it already.

Arioch

2013-01-16 11:07

developer   ~0020398

no, this both issues remain and file header still claims
// $Id: Utils.pas 13148 2011-11-05 17:27:59Z ahuser $

AHUser

2013-05-25 16:02

developer   ~0020511

Corrected in svn revision 13524.

Issue History

Date Modified Username Field Change
2012-09-03 13:30 Arioch New Issue
2013-01-15 15:29 obones Note Added: 0020357
2013-01-15 15:29 obones Status new => acknowledged
2013-01-16 11:07 Arioch Note Added: 0020398
2013-05-25 16:02 AHUser Note Added: 0020511
2013-05-25 16:02 AHUser Status acknowledged => resolved
2013-05-25 16:02 AHUser Fixed in Version => Daily / SVN
2013-05-25 16:02 AHUser Resolution open => fixed
2013-05-25 16:02 AHUser Assigned To => AHUser
2015-09-21 17:47 obones Fixed in Version Daily / GIT => 3.49