Stop LSL_Api.GetLinkEntities() from creating an unused list on every parameter except LINK_THIS. Simplify code.

0.8.0.3
Justin Clark-Casey (justincc) 2014-02-27 00:23:24 +00:00
parent ed760f2586
commit 91333b9267
1 changed files with 6 additions and 9 deletions

View File

@ -435,8 +435,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public List<ISceneEntity> GetLinkEntities(SceneObjectPart part, int linkType) public List<ISceneEntity> GetLinkEntities(SceneObjectPart part, int linkType)
{ {
List<ISceneEntity> ret = new List<ISceneEntity>(); List<ISceneEntity> ret;
ret.Add(part);
switch (linkType) switch (linkType)
{ {
@ -444,9 +443,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new List<ISceneEntity>(part.ParentGroup.Parts); return new List<ISceneEntity>(part.ParentGroup.Parts);
case ScriptBaseClass.LINK_ROOT: case ScriptBaseClass.LINK_ROOT:
ret = new List<ISceneEntity>(); return new List<ISceneEntity>() { part.ParentGroup.RootPart };
ret.Add(part.ParentGroup.RootPart);
return ret;
case ScriptBaseClass.LINK_ALL_OTHERS: case ScriptBaseClass.LINK_ALL_OTHERS:
ret = new List<ISceneEntity>(part.ParentGroup.Parts); ret = new List<ISceneEntity>(part.ParentGroup.Parts);
@ -461,10 +458,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (ret.Contains(part.ParentGroup.RootPart)) if (ret.Contains(part.ParentGroup.RootPart))
ret.Remove(part.ParentGroup.RootPart); ret.Remove(part.ParentGroup.RootPart);
return ret; return ret;
case ScriptBaseClass.LINK_THIS: case ScriptBaseClass.LINK_THIS:
return ret; return new List<ISceneEntity>() { part };
default: default:
if (linkType < 0) if (linkType < 0)
@ -473,9 +471,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ISceneEntity target = GetLinkEntity(part, linkType); ISceneEntity target = GetLinkEntity(part, linkType);
if (target == null) if (target == null)
return new List<ISceneEntity>(); return new List<ISceneEntity>();
ret = new List<ISceneEntity>();
ret.Add(target); return new List<ISceneEntity>() { target };
return ret;
} }
} }