Skip to content

Instantly share code, notes, and snippets.

@phrohdoh
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phrohdoh/11a6049d68dd4e12c580 to your computer and use it in GitHub Desktop.
Save phrohdoh/11a6049d68dd4e12c580 to your computer and use it in GitHub Desktop.
Which is faster? I assume the first.
var near = self.World.FindActorsInCircle(self.CenterPosition, info.Range);
foreach (var actor in near)
{
var foo = actor.TraitOrDefault<FooBar>();
if (foo == null) return;
// do stuff
}
var near = self.World.FindActorsInCircle(self.CenterPosition, info.Range)
.Where(a => a.HasTrait<FooBar>());
foreach (var actor in near)
{
var foo = actor.Trait<FooBar>();
// do stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment