View Single Post
  #176  
Old 07-04-2016, 08:14 PM
fzzzty
Fire Beetle
 
Join Date: Aug 2010
Posts: 23
Default

Quote:
Originally Posted by Tyen05 View Post
The "where" wasnt killing my fps, but changed it to below and kept the spawnlist array a list instead of switching to a dictionary:
GameObject temp = ObjectPool.instance.spawnlist.FirstOrDefault(obj => obj.name == spawn_id.ToString());
Forgive me if you know this already, but FirstOrDefault will return null if it doesn't find anything, so you might have to handle that (probably the same path as if the Where returned no entries). Where passes through the whole list even if it finds something, of course, so this should be faster if you're guaranteed to have the thing in the lsit. Alternatively, First will throw if it finds nothing. ToLookup might be useful in some situations in case you haven't heard of it. No offense if you already know all this.
Reply With Quote