Stop using, opt match { case Some(x) => f(x); case None => y } Stop using, http://opt.map (f).getOrElse(y) Use, opt.fold(y)(f) I feel like I'm very late to this party.
-
-
Initially, there wasn't any measurable gain. A replacement of fold by isDefined doubled throughput for the random distribution of Some and None values only after the external code was reduced to the simple while loop over an array of options.
-
Here is a gist for that benchmark with results in a top comment:https://gist.github.com/plokhotnyuk/a906b0039406f91b67b1cced25c06361 …
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.