Browse Source

* fixed fpc_AnsiStr_Concat in case when strings the same.

git-svn-id: trunk@5958 -
yury 18 years ago
parent
commit
97e6235535
1 changed files with 6 additions and 1 deletions
  1. 6 1
      rtl/inc/astrings.inc

+ 6 - 1
rtl/inc/astrings.inc

@@ -203,6 +203,7 @@ end;
 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
@@ -220,8 +221,12 @@ begin
   { Use Pointer() typecasts to prevent extra conversion code }
   if Pointer(DestS)=Pointer(S1) then
     begin
+      same:=Pointer(S1)=Pointer(S2);
       SetLength(DestS,Size+Location);
-      Move(Pointer(S2)^,(Pointer(DestS)+Location)^,Size+1);
+      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