Преглед на файлове

* patch by cobines to improve speed of TFPList.Move, resolves #21436

git-svn-id: trunk@20606 -
florian преди 13 години
родител
ревизия
a7fe7b5d06
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 4 3
      rtl/objpas/classes/lists.inc

+ 4 - 3
rtl/objpas/classes/lists.inc

@@ -255,9 +255,10 @@ begin
   if ((NewIndex < 0) or (NewIndex > Count -1)) then
     Error(SlistIndexError, NewIndex);
   Temp := FList^[CurIndex];
-  FList^[CurIndex] := nil;
-  Self.Delete(CurIndex);
-  Self.Insert(NewIndex, nil);
+  if NewIndex > CurIndex then
+    System.Move(FList^[CurIndex+1], FList^[CurIndex], (NewIndex - CurIndex) * SizeOf(Pointer))
+  else
+    System.Move(FList^[NewIndex], FList^[NewIndex+1], (CurIndex - NewIndex) * SizeOf(Pointer));
   FList^[NewIndex] := Temp;
 end;