I actually tested the code before posting it.
So did I:
var
Dirs:String = 'b\a\\1\\2\\3\\4\5\6789';
Dirs2:String;
begin
dirs := copy(dirs,1,111);
Dirs2:=dirs;
RepeatToSingleChar(Dirs,DirectorySeparator);
writeln( Dirs);
writeln( Dirs2);
readln;
end.
prints
b\a\1\2\3\4\5\6789
b\a\1\2\3\4\5\67896789
But "b" should still have the "\\" in it.
(fpc 3.0.4 / but that should not matter)
If u pull a string from a constant then u simply use uniquestring once on the string before entering the code.
Well, that is what I wrote. => Only that needs to be in the subroutine.
Because then, this needs only happen, if there needs to be any modification at all.
So if the string has no dups, you save the time of copying it around in memory (in case it had more than one ref)
As for mountain vs "mole hill" => I did not classify it.
I simply stated what happens
I posted my own suggestion, independent on it (and yes, it is based on your code.)