From 39d8ee11363e948505516eba0045b8ec4f7b1b04 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 28 Sep 2011 17:44:32 +0000 Subject: [PATCH] * Reverse IndexOf. Increases speed of freeing collection with a factor N^2 git-svn-id: trunk@19268 - --- rtl/objpas/classes/lists.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rtl/objpas/classes/lists.inc b/rtl/objpas/classes/lists.inc index cc10a1a10f..42a7e4e9dd 100644 --- a/rtl/objpas/classes/lists.inc +++ b/rtl/objpas/classes/lists.inc @@ -198,9 +198,9 @@ end; function TFPList.IndexOf(Item: Pointer): Integer; begin - Result := 0; - while(Result < FCount) and (Flist^[Result] <> Item) do Result := Result + 1; - If Result = FCount then Result := -1; + Result:=Count-1; + while (Result >=0) and (Flist^[Result]<>Item) do + Result:=Result - 1; end; procedure TFPList.Insert(Index: Integer; Item: Pointer);