From ae64d089c669a9f953fc0992ca4de3a700395def Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Jul 2012 21:05:51 +0100 Subject: refactor: In llRemoveInventory() use existing GetInventoryItem() method rather than have it iterate through TaskInventory itself. --- .../Shared/Api/Implementation/LSL_Api.cs | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8a3efa7..b52ebac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3934,20 +3934,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Name == name) - { - if (item.ItemID == m_item.ItemID) - throw new ScriptDeleteException(); - else - m_host.Inventory.RemoveInventoryItem(item.ItemID); - return; - } - } - } + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); + + if (item == null) + return; + + if (item.ItemID == m_item.ItemID) + throw new ScriptDeleteException(); + else + m_host.Inventory.RemoveInventoryItem(item.ItemID); } public void llSetText(string text, LSL_Vector color, double alpha) -- cgit v1.1