6 ms·
"I often have to back off of idiomatic Scala to achieve these goals (especially when it comes to GC pressure). " Can you give an example of when you had to do
by Aqueous 13y ago
"I often have to back off of idiomatic Scala to achieve these goals (especially when it comes to GC pressure). "
Can you give an example of when you had to do this? I often wonder about the performance costs of chaining together several collection API calls.
- kasey_junk 13y agoOptions are the most obvious: def foo(opt: Option[Bar]) = opt.map(_.toString).getOrElse("") This non-obviously creates an extra object in the Some case. As opposed to: if(opt.isDefined) opt.toString else "" which creates 0. Not a huge deal in this specific case (unless this is a hot call). But this sort of thing is endemic to all of the standard libraries. Edit -- only 1 extra object, but it is in both the Some & None case (which is sort of the point, it is hard to know with idiomatic Scala)