Avoid some minor allocations.

- Don't call string.Format in Actor.ToString since it gets called often, instead prefer a simple concat.
- In HiddenUnderFog.IsVisible, avoid a needless level of lambda indirection.
This commit is contained in:
RoosterDragon
2015-01-31 23:07:14 +00:00
parent 7e28acadd8
commit b4993efff1
2 changed files with 5 additions and 2 deletions

View File

@@ -181,7 +181,10 @@ namespace OpenRA
public override string ToString()
{
return "{0} {1}{2}".F(Info.Name, ActorID, IsInWorld ? "" : " (not in world)");
var name = Info.Name + " " + ActorID;
if (!IsInWorld)
name += " (not in world)";
return name;
}
public T Trait<T>()

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
{
public bool IsVisible(Actor self, Player byPlayer)
{
return byPlayer == null || Shroud.GetVisOrigins(self).Any(o => byPlayer.Shroud.IsVisible(o));
return byPlayer == null || Shroud.GetVisOrigins(self).Any(byPlayer.Shroud.IsVisible);
}
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)