URIParser needs optimization in 2 loops
Original Reporter info from Mantis: Alextpp @Alexey-T1
-
Reporter name: CudaText man
Original Reporter info from Mantis: Alextpp @Alexey-T1
- Reporter name: CudaText man
Description:
https://github.com/graemeg/freepascal/blob/master/packages/fcl-base/src/uriparser.pp
function URIToFilename
if PathDelim &LtPos;> '/' then begin I := Pos('/', Filename); while I > 0 do begin Filename[I] := PathDelim; I := Pos('/', Filename); end; end;
bad loop. loops N times.
either use a) StringReplace,
b) if you don't want to 'use' units, make simple loop over Filename
for I:=1 to Length(fn) do if fn[I]='/' then fn[I]:= PathDelim;
function FilenameToURI
if PathDelim &LtPos;> '/' then begin I := Pos(PathDelim, FilenamePart); while I &LtPos;> 0 do begin FilenamePart[I] := '/'; I := Pos(PathDelim, FilenamePart); end; end;
same note.
about bad loop.
Mantis conversion info:
- Mantis ID: 38474
- Version: 3.3.1
- Monitored by: » AntonK (Anton Kavalenka)