aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2017-04-04 20:11:11 +0100
committerUbitUmarov2017-04-04 20:11:11 +0100
commitd085c337a9d08788837a2f54a2400e91c807f59f (patch)
tree68f226067cbbad83526c3032c3b804b103e5d252 /OpenSim/Region
parent add LSL_Integer osGetLinkNumber(LSL_String name). uses a cache for the strin... (diff)
downloadopensim-SC_OLD-d085c337a9d08788837a2f54a2400e91c807f59f.zip
opensim-SC_OLD-d085c337a9d08788837a2f54a2400e91c807f59f.tar.gz
opensim-SC_OLD-d085c337a9d08788837a2f54a2400e91c807f59f.tar.bz2
opensim-SC_OLD-d085c337a9d08788837a2f54a2400e91c807f59f.tar.xz
add a little speedup on repeated requests for same name on osGetLinkNumber.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs35
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs1
2 files changed, 29 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index b410b74..d3490c2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -5340,7 +5340,9 @@ namespace OpenSim.Region.Framework.Scenes
5340 m_partsNameToLinkMap.Clear(); 5340 m_partsNameToLinkMap.Clear();
5341 } 5341 }
5342 5342
5343 Dictionary<string,int> m_partsNameToLinkMap = new Dictionary<string, int>(); 5343 private Dictionary<string,int> m_partsNameToLinkMap = new Dictionary<string, int>();
5344 private string GetLinkNumber_lastname;
5345 private int GetLinkNumber_lastnumber;
5344 5346
5345 // this scales bad but so does GetLinkNumPart 5347 // this scales bad but so does GetLinkNumPart
5346 public int GetLinkNumber(string name) 5348 public int GetLinkNumber(string name)
@@ -5352,6 +5354,8 @@ namespace OpenSim.Region.Framework.Scenes
5352 { 5354 {
5353 if(m_partsNameToLinkMap.Count == 0) 5355 if(m_partsNameToLinkMap.Count == 0)
5354 { 5356 {
5357 GetLinkNumber_lastname = String.Empty;
5358 GetLinkNumber_lastnumber = -1;
5355 SceneObjectPart[] parts = m_parts.GetArray(); 5359 SceneObjectPart[] parts = m_parts.GetArray();
5356 for (int i = 0; i < parts.Length; i++) 5360 for (int i = 0; i < parts.Length; i++)
5357 { 5361 {
@@ -5370,20 +5374,33 @@ namespace OpenSim.Region.Framework.Scenes
5370 } 5374 }
5371 } 5375 }
5372 5376
5377 if(name == GetLinkNumber_lastname)
5378 return GetLinkNumber_lastnumber;
5379
5373 if(m_partsNameToLinkMap.ContainsKey(name)) 5380 if(m_partsNameToLinkMap.ContainsKey(name))
5374 return m_partsNameToLinkMap[name]; 5381 {
5375 } 5382 lock(m_partsNameToLinkMap)
5383 {
5384 GetLinkNumber_lastname = name;
5385 GetLinkNumber_lastnumber = m_partsNameToLinkMap[name];
5386 return GetLinkNumber_lastnumber;
5387 }
5388 }
5389 }
5376 5390
5377 if(m_sittingAvatars.Count > 0) 5391 if(m_sittingAvatars.Count > 0)
5378 { 5392 {
5379 int j = m_parts.Count; 5393 int j = m_parts.Count + 1;
5380 if(j > 1) 5394
5381 j++;
5382 ScenePresence[] avs = m_sittingAvatars.ToArray(); 5395 ScenePresence[] avs = m_sittingAvatars.ToArray();
5383 for (int i = 0; i < avs.Length; i++, j++) 5396 for (int i = 0; i < avs.Length; i++, j++)
5384 { 5397 {
5385 if (avs[i].Name == name) 5398 if (avs[i].Name == name)
5386 return j; 5399 {
5400 GetLinkNumber_lastname = name;
5401 GetLinkNumber_lastnumber = j;
5402 return j;
5403 }
5387 } 5404 }
5388 } 5405 }
5389 5406
@@ -5393,7 +5410,11 @@ namespace OpenSim.Region.Framework.Scenes
5393 public void InvalidatePartsLinkMaps() 5410 public void InvalidatePartsLinkMaps()
5394 { 5411 {
5395 lock(m_partsNameToLinkMap) 5412 lock(m_partsNameToLinkMap)
5413 {
5396 m_partsNameToLinkMap.Clear(); 5414 m_partsNameToLinkMap.Clear();
5415 GetLinkNumber_lastname = String.Empty;
5416 GetLinkNumber_lastnumber = -1;
5417 }
5397 } 5418 }
5398 5419
5399 #endregion 5420 #endregion
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 879fe51..08b144a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -497,5 +497,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
497 void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot); 497 void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot);
498 498
499 void osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags); 499 void osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags);
500 LSL_Integer osGetLinkNumber(LSL_String name);
500 } 501 }
501} 502}