Use SP.ParentPart instead of ParentID in places where it's more efficient (saving extra null checks, etc.)

However, it looks like we should retain SP.ParentID since it's much easier to use that in places where another thread could change ParentPart to null.
Otherwise one has to clumsily put ParentPart in a reference, etc. to avoid a race.
This commit is contained in:
Justin Clark-Casey (justincc)
2012-03-09 02:38:11 +00:00
parent b454326273
commit 94e58ff6b9
4 changed files with 32 additions and 68 deletions

View File

@@ -3825,7 +3825,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List<String> nametable = new List<String>();
World.ForEachRootScenePresence(delegate(ScenePresence presence)
{
if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
SceneObjectPart sitPart = presence.ParentPart;
if (sitPart != null && m_host.ParentGroup.HasChildPrim(sitPart.LocalId))
nametable.Add(presence.ControllingClient.Name);
});
@@ -4393,22 +4394,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// Find pushee position
// Pushee Linked?
if (pusheeav.ParentID != 0)
{
SceneObjectPart parentobj = World.GetSceneObjectPart(pusheeav.ParentID);
if (parentobj != null)
{
PusheePos = parentobj.AbsolutePosition;
}
else
{
PusheePos = pusheeav.AbsolutePosition;
}
}
SceneObjectPart sitPart = pusheeav.ParentPart;
if (sitPart != null)
PusheePos = sitPart.AbsolutePosition;
else
{
PusheePos = pusheeav.AbsolutePosition;
}
}
if (!pusheeIsAvatar)
@@ -5603,7 +5593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
flags |= ScriptBaseClass.AGENT_IN_AIR;
}
if (agent.ParentID != 0)
if (agent.ParentPart != null)
{
flags |= ScriptBaseClass.AGENT_ON_OBJECT;
flags |= ScriptBaseClass.AGENT_SITTING;
@@ -7692,7 +7682,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
World.ForEachRootScenePresence(delegate(ScenePresence presence)
{
if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
avatarCount++;
avatarCount++;
});
return m_host.ParentGroup.PrimCount + avatarCount;