diff options
author | Rex Kerr <ichoran@gmail.com> | 2015-02-13 16:37:19 -0800 |
---|---|---|
committer | Rex Kerr <ichoran@gmail.com> | 2015-03-30 16:56:00 -0700 |
commit | 56c1af90999f0a9a55a90f3dd3bf6d04ddda5943 (patch) | |
tree | f9a5cd4aa1d2b8b84469ea4823be2968e418764f /build.number | |
parent | 955eb2170e1291500813e6bec76a9f0e1e3bad50 (diff) | |
download | scala-56c1af90999f0a9a55a90f3dd3bf6d04ddda5943.tar.gz scala-56c1af90999f0a9a55a90f3dd3bf6d04ddda5943.tar.bz2 scala-56c1af90999f0a9a55a90f3dd3bf6d04ddda5943.zip |
Performance improvement: collectFirst in TraversableOnce
collectFirst was implemented in TraversableOnce by calling toIterator and then using a non-local return to pull out a Some when the partial function succeeded. This had two problems:
1. If the TraversableOnce was Iterator or Iterable, stepping through until pf is happy is much (15x!) faster.
2. If the TraversableOnce was not, creating an Iterator is a waste of time and memory
This fixes both of these issues by inspecting the self-type and choosing the appropriate implementation.
Further (modest) improvements likely possible in 2.12 by moving specialized implementations to child classes and using `applyOrElse` on the partial function with a package-private object instead of a locally created one.
Diffstat (limited to 'build.number')
0 files changed, 0 insertions, 0 deletions