* Minor improvement. No need to move the terminating null char, since it is written later anyway. Remove a local var.

git-svn-id: trunk@44960 -
This commit is contained in:
yury 2020-04-21 14:18:35 +00:00
parent ef790adc28
commit 1e32b96bc2

View File

@ -766,8 +766,7 @@ Procedure fpc_AnsiStr_SetLength (Var S : RawByteString; l : SizeInt{$ifdef FPC_H
}
Var
Temp : Pointer;
lens, lena,
movelen : SizeInt;
lens, lena : SizeInt;
begin
if (l>0) then
begin
@ -798,13 +797,10 @@ begin
{ Reallocation is needed... }
Temp:=NewAnsiString(L);
PAnsiRec(Pointer(Temp)-AnsiFirstOff)^.CodePage:=PAnsiRec(Pointer(S)-AnsiFirstOff)^.CodePage;
{ also move terminating null }
lens:=succ(length(s));
lens:=length(s);
if l<lens then
movelen:=l
else
movelen:=lens;
Move(Pointer(S)^,Temp^,movelen);
lens:=l;
Move(Pointer(S)^,Temp^,lens);
fpc_ansistr_decr_ref(Pointer(s));
Pointer(S):=Temp;
end;