26 ms·
There is no performance difference here, map etc. are producing the same garbage. Scala isn't Haskell. Also note that there is a HUGE performance difference bet
by auggierose 13y ago
There is no performance difference here, map etc. are producing the same garbage. Scala isn't Haskell. Also note that there is a HUGE performance difference between appending and prepeding to a list. :-)
- bad_user 13y agoIf you need to append, use a Vector instead.
- GyrosOfWar 13y ago> Also note that there is a HUGE performance difference between appending and prepeding to a list. :-) If you're going to do a lot of appending, might I suggest a ListBuffer or a Vector?
- mark242 13y agoI don't think that's right. TraversableLike, and FilterMonadic will both size up the resulting return value based upon the length of what's passed to it. You'll get a List of N items, and the call to flatMap will also traverse the list to remove/flatten the Options. Items will then get dropped in the List. You're looking at one or two collectable objects every time you run through that method, as opposed to bin.items.length collectable objects in your original code. Look at it this way-- what happens if bin.items is a List() of 10M objects? completed_items can be replaced up to 10M times. The .flatMap creates one collection of 10M length, removes the None objects, and returns the resulting List.