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 --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 121 ++++++++++----------- 1 file changed, 60 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 32171a0..7193002 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1077,8 +1077,8 @@ if (m_shape != null) { private void SendObjectPropertiesToClient(UUID AgentID) { - List avatars = m_parentGroup.Scene.GetScenePresences(); - for (int i = 0; i < avatars.Count; i++) + ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); + for (int i = 0; i < avatars.Length; i++) { // Ugly reference :( if (avatars[i].UUID == AgentID) @@ -1140,8 +1140,8 @@ if (m_shape != null) { /// public void AddFullUpdateToAllAvatars() { - List avatars = m_parentGroup.Scene.GetScenePresences(); - for (int i = 0; i < avatars.Count; i++) + ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); + for (int i = 0; i < avatars.Length; i++) { avatars[i].SceneViewer.QueuePartForUpdate(this); } @@ -1165,8 +1165,8 @@ if (m_shape != null) { /// Terse updates public void AddTerseUpdateToAllAvatars() { - List avatars = m_parentGroup.Scene.GetScenePresences(); - for (int i = 0; i < avatars.Count; i++) + ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); + for (int i = 0; i < avatars.Length; i++) { avatars[i].SceneViewer.QueuePartForUpdate(this); } @@ -1894,24 +1894,24 @@ if (m_shape != null) { } else { - List avlist = m_parentGroup.Scene.GetScenePresences(); - if (avlist != null) + ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); + + for (int i = 0; i < avlist.Length; i++) { - foreach (ScenePresence av in avlist) + ScenePresence av = avlist[i]; + + if (av.LocalId == localId) { - if (av.LocalId == localId) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = av.UUID; + detobj.nameStr = av.ControllingClient.Name; + detobj.ownerUUID = av.UUID; + detobj.posVector = av.AbsolutePosition; + detobj.rotQuat = av.Rotation; + detobj.velVector = av.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = av.ControllingClient.ActiveGroupId; + colliding.Add(detobj); } } } @@ -1965,26 +1965,25 @@ if (m_shape != null) { } else { - List avlist = m_parentGroup.Scene.GetScenePresences(); - if (avlist != null) + ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); + + for (int i = 0; i < avlist.Length; i++) { - foreach (ScenePresence av in avlist) + ScenePresence av = avlist[i]; + + if (av.LocalId == localId) { - if (av.LocalId == localId) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = av.UUID; + detobj.nameStr = av.Name; + detobj.ownerUUID = av.UUID; + detobj.posVector = av.AbsolutePosition; + detobj.rotQuat = av.Rotation; + detobj.velVector = av.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = av.ControllingClient.ActiveGroupId; + colliding.Add(detobj); } - } } } @@ -2035,24 +2034,24 @@ if (m_shape != null) { } else { - List avlist = m_parentGroup.Scene.GetScenePresences(); - if (avlist != null) + ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); + + for (int i = 0; i < avlist.Length; i++) { - foreach (ScenePresence av in avlist) + ScenePresence av = avlist[i]; + + if (av.LocalId == localId) { - if (av.LocalId == localId) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = av.UUID; + detobj.nameStr = av.Name; + detobj.ownerUUID = av.UUID; + detobj.posVector = av.AbsolutePosition; + detobj.rotQuat = av.Rotation; + detobj.velVector = av.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = av.ControllingClient.ActiveGroupId; + colliding.Add(detobj); } } } @@ -2312,8 +2311,8 @@ if (m_shape != null) { /// public void SendFullUpdateToAllClients() { - List avatars = m_parentGroup.Scene.GetScenePresences(); - for (int i = 0; i < avatars.Count; i++) + ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); + for (int i = 0; i < avatars.Length; i++) { // Ugly reference :( m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, @@ -2323,8 +2322,8 @@ if (m_shape != null) { public void SendFullUpdateToAllClientsExcept(UUID agentID) { - List avatars = m_parentGroup.Scene.GetScenePresences(); - for (int i = 0; i < avatars.Count; i++) + ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); + for (int i = 0; i < avatars.Length; i++) { // Ugly reference :( if (avatars[i].UUID != agentID) @@ -2467,8 +2466,8 @@ if (m_shape != null) { /// public void SendTerseUpdateToAllClients() { - List avatars = m_parentGroup.Scene.GetScenePresences(); - for (int i = 0; i < avatars.Count; i++) + ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); + for (int i = 0; i < avatars.Length; i++) { SendTerseUpdateToClient(avatars[i].ControllingClient); } -- cgit v1.1