[Lazarus] FileUtil.FindAllFiles - changes strings inside

AlexeyT aaa5500 at ya.ru
Mon Sep 21 00:19:23 CEST 2020


procedure TFileSearcher.Search(ASearchPath: String; ASearchMask: String;
   ASearchSubDirs: Boolean; CaseSensitive: Boolean = False);

     while ASearchPath<>'' do begin
       p:=Pos(FPathSeparator,ASearchPath);
       if p<1 then
         p:=length(ASearchPath)+1;
       Dir:=ResolveDots(LeftStr(ASearchPath,p-1));
       Delete(ASearchPath,1,p);


you see that to iterate over all items in char-separated ASearchPath, 
code modifies str, ie deletes parts of it. It's slow! We should not 
modify str here. It's easy- save old-index, new-index, and get Copy(n1, 
n2-n1{+delta}).

Didn't see why ASearchMask is not "const", maybe same bad.

Alexey Torgashin



More information about the lazarus mailing list