aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-23 01:02:36 -0700
committerJohn Hurliman2009-10-23 01:02:36 -0700
commit588361e2a2398b963871762c2b5485c6a086cf47 (patch)
tree5be2c6705096817c599075da4e12a0e9b0a4c841 /OpenSim/Region/ScriptEngine
parentAdded VS2010 support to Prebuild and created runprebuild2010.bat (diff)
downloadopensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.zip
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.gz
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.bz2
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.xz
Experimental change to use an immutable array for iterating ScenePresences, avoiding locking and copying the list each time it is accessed
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs13
2 files changed, 12 insertions, 9 deletions
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
7227 public LSL_Integer llGetNumberOfPrims() 7227 public LSL_Integer llGetNumberOfPrims()
7228 { 7228 {
7229 m_host.AddScriptLPS(1); 7229 m_host.AddScriptLPS(1);
7230 List<ScenePresence> presences = World.GetScenePresences(); 7230 ScenePresence[] presences = World.GetScenePresences();
7231 if (presences.Count == 0) 7231 if (presences.Length == 0)
7232 return 0; 7232 return 0;
7233 7233
7234 int avatarCount = 0; 7234 int avatarCount = 0;
7235 foreach (ScenePresence presence in presences) 7235 for (int i = 0; i < presences.Length; i++)
7236 { 7236 {
7237 ScenePresence presence = presences[i];
7238
7237 if (!presence.IsChildAgent && presence.ParentID != 0) 7239 if (!presence.IsChildAgent && presence.ParentID != 0)
7238 { 7240 {
7239 if (m_host.ParentGroup.HasChildPrim(presence.ParentID)) 7241 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
404 404
405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) 405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
406 { 406 {
407 List<ScenePresence> Presences; 407 List<ScenePresence> presences;
408 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 408 List<SensedEntity> sensedEntities = new List<SensedEntity>();
409 409
410 // If this is an avatar sense by key try to get them directly 410 // If this is an avatar sense by key try to get them directly
@@ -414,16 +414,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
414 ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID); 414 ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID);
415 if (p == null) 415 if (p == null)
416 return sensedEntities; 416 return sensedEntities;
417 Presences = new List<ScenePresence>(); 417 presences = new List<ScenePresence>();
418 Presences.Add(p); 418 presences.Add(p);
419 } 419 }
420 else 420 else
421 { 421 {
422 Presences = m_CmdManager.m_ScriptEngine.World.GetScenePresences(); 422 presences = new List<ScenePresence>(m_CmdManager.m_ScriptEngine.World.GetScenePresences());
423 } 423 }
424 424
425 // If nobody about quit fast 425 // If nobody about quit fast
426 if (Presences.Count == 0) 426 if (presences.Count == 0)
427 return sensedEntities; 427 return sensedEntities;
428 428
429 SceneObjectPart SensePoint = ts.host; 429 SceneObjectPart SensePoint = ts.host;
@@ -440,8 +440,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
440 Vector3 toRegionPos; 440 Vector3 toRegionPos;
441 double dis; 441 double dis;
442 442
443 foreach (ScenePresence presence in Presences) 443 for (int i = 0; i < presences.Count; i++)
444 { 444 {
445 ScenePresence presence = presences[i];
445 bool keep = true; 446 bool keep = true;
446 447
447 if (presence.IsDeleted) 448 if (presence.IsDeleted)