Skip to content

Improvement of function ExtractFileUnitName

packages/fcl-passrc/src/pscanner.pp has

function ExtractFileUnitName(aFilename: String): String;
var
  p: Integer;
begin
  Result:=ExtractFileName(aFilename);
  if Result='' then exit;
  for p:=length(Result) downto 1 do
    case Result[p] of
    '/','\': exit;
    '.':
      begin
      Delete(Result,p,length(Result));
      exit;
      end;
    end;
end;

Delete(Result,p,length(Result)); produces a conditional jump when computing length(ansistring) which can be avoided by replacing Delete with SetLength(Result,p-1);.

Here is a patch.patch.diff

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information