optimize TStringHelper.StartsWith / EndsWith
rtl/objpas/sysutils/syshelp.inc
function TStringHelper.StartsWith(const AValue: string; IgnoreCase: Boolean
): Boolean;
Var
L : SizeInt;
S : String;
begin
L:=System.Length(AValue);
Result:=L<=0;
if not Result then
begin
S:=System.Copy(Self,1,L);
Result:=(System.Length(S)=L);
if Result then
if IgnoreCase then
Result:=SameText(S,aValue)
else
Result:=SameStr(S,AValue);
end;
end;
Can we avoid Copy() call here, and compare parts of string using stricomp / for-loops?
The same for TStringHelper.EndsWith
Edited by Alexey Torgashin