Browse Source

* Applied cleanup patch from Luiz Americo (Bug 21771)

git-svn-id: trunk@20867 -
michael 13 years ago
parent
commit
0aa0d3f584
1 changed files with 13 additions and 17 deletions
  1. 13 17
      rtl/objpas/classes/collect.inc

+ 13 - 17
rtl/objpas/classes/collect.inc

@@ -153,10 +153,7 @@ end;
 function TCollection.GetCount: Integer;
 function TCollection.GetCount: Integer;
 
 
 begin
 begin
-  If Assigned(FItems) Then
-    Result:=FItems.Count
-  else
-    Result:=0;
+  Result:=FItems.Count;
 end;
 end;
 
 
 
 
@@ -254,11 +251,11 @@ end;
 
 
 
 
 function TCollection.GetNamePath: string;
 function TCollection.GetNamePath: string;
-var o : TObject;
+var o : TPersistent;
 begin
 begin
   o:=getowner;
   o:=getowner;
-  if assigned(o) and (propname<>'') and (o IS TPersistent) then 
-     result:=TPersistent(o).getnamepath+'.'+propname
+  if assigned(o) and (propname<>'') then 
+     result:=o.getnamepath+'.'+propname
    else
    else
      result:=classname;
      result:=classname;
 end;
 end;
@@ -304,11 +301,8 @@ end;
 
 
 destructor TCollection.Destroy;
 destructor TCollection.Destroy;
 begin
 begin
-  If Assigned(FItems) Then 
-    begin
-    BeginUpdate; // Prevent OnChange
-    DoClear;
-    end;
+  BeginUpdate; // Prevent OnChange
+  DoClear;
   FItems.Free;
   FItems.Free;
   Inherited Destroy;
   Inherited Destroy;
 end;
 end;
@@ -343,7 +337,7 @@ end;
 
 
 procedure TCollection.Clear;
 procedure TCollection.Clear;
 begin
 begin
-  if (FItems=Nil) or (FItems.Count=0) then
+  if FItems.Count=0 then
     exit; // Prevent Changed
     exit; // Prevent Changed
   BeginUpdate;
   BeginUpdate;
   try
   try
@@ -356,8 +350,7 @@ end;
 
 
 procedure TCollection.DoClear;
 procedure TCollection.DoClear;
 begin
 begin
-  If Assigned(FItems) then
-    While FItems.Count>0 do TCollectionItem(FItems.Last).Free;
+  While FItems.Count>0 do TCollectionItem(FItems.Last).Free;
 end;
 end;
 
 
 
 
@@ -384,9 +377,12 @@ end;
 
 
 
 
 procedure TCollection.Delete(Index: Integer);
 procedure TCollection.Delete(Index: Integer);
+Var
+  Item : TCollectionItem;
 begin
 begin
-  Notify(TCollectionItem(FItems[Index]),cnDeleting);
-  TCollectionItem(FItems[Index]).Free;
+  Item:=TCollectionItem(FItems[Index]);
+  Notify(Item,cnDeleting);
+  Item.Free;
 end;
 end;