From 1e32b96bc230cd044d6c37faeb5a63e55408778a Mon Sep 17 00:00:00 2001 From: yury <jura@cp-lab.com> Date: Tue, 21 Apr 2020 14:18:35 +0000 Subject: [PATCH] * 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 - --- rtl/inc/astrings.inc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rtl/inc/astrings.inc b/rtl/inc/astrings.inc index 711231d298..721e919ad5 100644 --- a/rtl/inc/astrings.inc +++ b/rtl/inc/astrings.inc @@ -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;