From 588361e2a2398b963871762c2b5485c6a086cf47 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 23 Oct 2009 01:02:36 -0700 Subject: Experimental change to use an immutable array for iterating ScenePresences, avoiding locking and copying the list each time it is accessed --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 +++++--- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 669189d..56d4d28 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7227,13 +7227,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetNumberOfPrims() { m_host.AddScriptLPS(1); - List presences = World.GetScenePresences(); - if (presences.Count == 0) + ScenePresence[] presences = World.GetScenePresences(); + if (presences.Length == 0) return 0; int avatarCount = 0; - foreach (ScenePresence presence in presences) + for (int i = 0; i < presences.Length; i++) { + ScenePresence presence = presences[i]; + if (!presence.IsChildAgent && presence.ParentID != 0) { if (m_host.ParentGroup.HasChildPrim(presence.ParentID)) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index a09c8db..ee01c3c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -404,7 +404,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins private List doAgentSensor(SenseRepeatClass ts) { - List Presences; + List presences; List sensedEntities = new List(); // If this is an avatar sense by key try to get them directly @@ -414,16 +414,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID); if (p == null) return sensedEntities; - Presences = new List(); - Presences.Add(p); + presences = new List(); + presences.Add(p); } else { - Presences = m_CmdManager.m_ScriptEngine.World.GetScenePresences(); + presences = new List(m_CmdManager.m_ScriptEngine.World.GetScenePresences()); } // If nobody about quit fast - if (Presences.Count == 0) + if (presences.Count == 0) return sensedEntities; SceneObjectPart SensePoint = ts.host; @@ -440,8 +440,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins Vector3 toRegionPos; double dis; - foreach (ScenePresence presence in Presences) + for (int i = 0; i < presences.Count; i++) { + ScenePresence presence = presences[i]; bool keep = true; if (presence.IsDeleted) -- cgit v1.1