From 51bc19f1abd63d4a9d3d463a2c1f9d1fa0dc366a Mon Sep 17 00:00:00 2001
From: UbitUmarov <ajlduarte@sapo.pt>
Date: Tue, 12 May 2020 18:58:07 +0100
Subject: [PATCH] no need to clone something Idisposable when we just want to
 see values

---
 OpenSim/Framework/TaskInventoryDictionary.cs    |  6 +-----
 OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 11 ++++-------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs
index 21e39c0de3..d1a112a69a 100644
--- a/OpenSim/Framework/TaskInventoryDictionary.cs
+++ b/OpenSim/Framework/TaskInventoryDictionary.cs
@@ -267,12 +267,8 @@ namespace OpenSim.Framework
 
         public List<TaskInventoryItem> GetItems()
         {
-            var ret = new List<TaskInventoryItem>(this.Count);
             m_itemLock.EnterReadLock();
-            foreach (TaskInventoryItem it in Values)
-            {
-                ret.Add(it);
-            }
+            var ret = new List<TaskInventoryItem>(Values);
             m_itemLock.ExitReadLock();
             return ret;
         }
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index c23004e174..732c57e013 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -397,14 +397,12 @@ namespace OpenSim.Region.Framework.Scenes
                         }
                     }
 
-                    TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
-
+                    List<TaskInventoryItem> items = part.TaskInventory.GetItems();
                     // Now analyze this prim's inventory items to preserve all the uuids that they reference
-                    foreach (TaskInventoryItem tii in taskDictionary.Values)
+                    for(i = 0; i < items.Count; ++i)
                     {
-                        //                        m_log.DebugFormat(
-                        //                            "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}",
-                        //                            tii.Name, tii.Type, part.Name, part.UUID);
+                        TaskInventoryItem tii = items[i];
+                        items[i] = null; // gc is stupid
                         AddForInspection(tii.AssetID, (sbyte)tii.Type);
                     }
 
@@ -414,7 +412,6 @@ namespace OpenSim.Region.Framework.Scenes
                     // Scene.EventManager is present.
                     //                    part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
 
-
                     // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
                     RecordMaterialsUuids(part);
                 }