瀏覽代碼

* 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 -
yury 5 年之前
父節點
當前提交
1e32b96bc2
共有 1 個文件被更改,包括 4 次插入8 次删除
  1. 4 8
      rtl/inc/astrings.inc

+ 4 - 8
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;