add a little speedup on repeated requests for same name on osGetLinkNumber.

httptests
UbitUmarov 2017-04-04 20:11:11 +01:00
parent e237e1b2fa
commit d085c337a9
2 changed files with 29 additions and 7 deletions

View File

@ -5340,7 +5340,9 @@ namespace OpenSim.Region.Framework.Scenes
m_partsNameToLinkMap.Clear();
}
Dictionary<string,int> m_partsNameToLinkMap = new Dictionary<string, int>();
private Dictionary<string,int> m_partsNameToLinkMap = new Dictionary<string, int>();
private string GetLinkNumber_lastname;
private int GetLinkNumber_lastnumber;
// this scales bad but so does GetLinkNumPart
public int GetLinkNumber(string name)
@ -5352,6 +5354,8 @@ namespace OpenSim.Region.Framework.Scenes
{
if(m_partsNameToLinkMap.Count == 0)
{
GetLinkNumber_lastname = String.Empty;
GetLinkNumber_lastnumber = -1;
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
@ -5370,20 +5374,33 @@ namespace OpenSim.Region.Framework.Scenes
}
}
if(name == GetLinkNumber_lastname)
return GetLinkNumber_lastnumber;
if(m_partsNameToLinkMap.ContainsKey(name))
return m_partsNameToLinkMap[name];
}
{
lock(m_partsNameToLinkMap)
{
GetLinkNumber_lastname = name;
GetLinkNumber_lastnumber = m_partsNameToLinkMap[name];
return GetLinkNumber_lastnumber;
}
}
}
if(m_sittingAvatars.Count > 0)
{
int j = m_parts.Count;
if(j > 1)
j++;
int j = m_parts.Count + 1;
ScenePresence[] avs = m_sittingAvatars.ToArray();
for (int i = 0; i < avs.Length; i++, j++)
{
if (avs[i].Name == name)
return j;
{
GetLinkNumber_lastname = name;
GetLinkNumber_lastnumber = j;
return j;
}
}
}
@ -5393,7 +5410,11 @@ namespace OpenSim.Region.Framework.Scenes
public void InvalidatePartsLinkMaps()
{
lock(m_partsNameToLinkMap)
{
m_partsNameToLinkMap.Clear();
GetLinkNumber_lastname = String.Empty;
GetLinkNumber_lastnumber = -1;
}
}
#endregion

View File

@ -497,5 +497,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot);
void osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags);
LSL_Integer osGetLinkNumber(LSL_String name);
}
}