thanks Luiz for your help,
it seems that it is the code added for codepage in string functions which increase execution time :
for example function fpc_AnsiStr_Concat in rtl/inc/asstrings.inc :
fpc 2.6.3 :
procedure fpc_AnsiStr_Concat (var DestS:ansistring;const S1,S2 : AnsiString); compilerproc;
Var
Size,Location : SizeInt;
same : boolean;
begin
{ only assign if s1 or s2 is empty }
if (S1='') then
begin
DestS:=s2;
exit;
end;
if (S2='') then
begin
DestS:=s1;
exit;
end;
Location:=Length(S1);
Size:=length(S2);
{ Use Pointer() typecasts to prevent extra conversion code }
if Pointer(DestS)=Pointer(S1) then
begin
same:=Pointer(S1)=Pointer(S2);
SetLength(DestS,Size+Location);
if same then
Move(Pointer(DestS)^,(Pointer(DestS)+Location)^,Size)
else
Move(Pointer(S2)^,(Pointer(DestS)+Location)^,Size+1);
end
else if Pointer(DestS)=Pointer(S2) then
begin
SetLength(DestS,Size+Location);
Move(Pointer(DestS)^,(Pointer(DestS)+Location)^,Size+1);
Move(Pointer(S1)^,Pointer(DestS)^,Location);
end
else
begin
DestS:='';
SetLength(DestS,Size+Location);
Move(Pointer(S1)^,Pointer(DestS)^,Location);
Move(Pointer(S2)^,(Pointer(DestS)+Location)^,Size+1);
end;
end;
fpc 2.7.1 :
procedure fpc_AnsiStr_Concat (var DestS:RawByteString;const S1,S2 : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
Var
S1Len, S2Len: SizeInt;
same : boolean;
S1CP, S2CP, DestCP: TSystemCodePage;
begin
{$ifdef FPC_HAS_CPSTRING}
if (Pointer(DestS)=nil) then
DestCP:=cp
else
DestCP:=StringCodePage(DestS);
{$else FPC_HAS_CPSTRING}
DestCP:=StringCodePage(DestS);
{$endif FPC_HAS_CPSTRING}
if (DestCP=CP_ACP) then
DestCP:=DefaultSystemCodePage;
{ if codepages are different then concat using unicodestring,
but avoid conversions if either addend is empty (StringCodePage will return
DefaultSystemCodePage in that case, which may differ from other addend/dest) }
if S1='' then
S1CP:=DestCP
else
S1CP:=StringCodePage(S1);
if (S1CP=CP_ACP) then
S1CP:=DefaultSystemCodePage;
if S2='' then
S2CP:=DestCP
else
S2CP:=StringCodePage(S2);
if (S2CP=CP_ACP) then
S2CP:=DefaultSystemCodePage;
if (S1CP<>DestCP) or (S2CP<>DestCP) then
begin
ansistr_concat_complex(DestS,S1,S2,DestCP);
exit;
end;
{ only assign if s1 or s2 is empty }
if (S1='') then
begin
DestS:=s2;
exit;
end;
if (S2='') then
begin
DestS:=s1;
exit;
end;
S1Len:=Length(S1);
S2Len:=length(S2);
{ Use Pointer() typecasts to prevent extra conversion code }
if Pointer(DestS)=Pointer(S1) then
begin
same:=Pointer(S1)=Pointer(S2);
SetLength(DestS,S1Len+S2Len);
if same then
fpc_pchar_ansistr_intern_charmove(PAnsiChar(DestS),0,DestS,S1Len,S2Len)
else
fpc_pchar_ansistr_intern_charmove(PAnsiChar(S2),0,DestS,S1Len,S2Len+1)
end
else if Pointer(DestS)=Pointer(S2) then
begin
SetLength(DestS,S1Len+S2Len);
fpc_pchar_ansistr_intern_charmove(PAnsiChar(DestS),0,DestS,S1Len,S2Len+1);
fpc_pchar_ansistr_intern_charmove(PAnsiChar(S1),0,DestS,0,S1Len);
end
else
begin
SetLength(DestS,S1Len+S2Len);
fpc_pchar_ansistr_intern_charmove(PAnsiChar(S1),0,DestS,0,S1Len);
fpc_pchar_ansistr_intern_charmove(PAnsiChar(S2),0,DestS,S1Len,S2Len+1);
end;
SetCodePage(DestS,DestCP,false);
end;
tip :
when i replace strings by shortstrings in my source code :
Elapsed Time on Windows 7 Q8300 processor :
fpc 2.6.3 -> 1.0 seconds
fpc 2.7.1 -> 1.6 seconds