浏览代码

* 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
   if ((NewIndex < 0) or (NewIndex > Count -1)) then
     Error(SlistIndexError, NewIndex);
     Error(SlistIndexError, NewIndex);
   Temp := FList^[CurIndex];
   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;
   FList^[NewIndex] := Temp;
 end;
 end;