Skip to content

Commit

Permalink
Reverted addition of 5 specialized method from LinearSeqOptimized to …
Browse files Browse the repository at this point in the history
…List.

It seems any gains were more then compensated by the loss of making map polymorphic, probably preventing inlining decisions in Hotspot.
  • Loading branch information
odersky authored and gkossakowski committed Aug 20, 2012
1 parent 82c6168 commit 80ba578
Showing 1 changed file with 0 additions and 56 deletions.
56 changes: 0 additions & 56 deletions src/library/scala/collection/immutable/List.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,62 +310,6 @@ sealed abstract class List[+A] extends AbstractSeq[A]
these = these.tail
}
}

@inline override /*TraversableLike*/
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[List[A], B, That]): That = {
val b = bf(repr)
var these = this
while (!these.isEmpty) {
b += f(these.head)
these = these.tail
}
b.result
}

@inline override /*TraversableLike*/
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[List[A], B, That]): That = {
val b = bf(repr)
var these = this
while (!these.isEmpty) {
b ++= f(these.head).seq
these = these.tail
}
b.result
}

@inline override /*TraversableLike*/
def filter(p: A => Boolean): List[A] = {
val b = newBuilder
var these = this
while (!these.isEmpty) {
val x = these.head
if (p(x)) b += x
these = these.tail
}
b.result
}

@inline override /*TraversableLike*/
def filterNot(p: A => Boolean): List[A] = {
val b = newBuilder
var these = this
while (!these.isEmpty) {
val x = these.head
if (!p(x)) b += x
these = these.tail
}
b.result
}

@inline override /*SeqLike*/
def contains(elem: Any): Boolean = {
var these = this
while (!these.isEmpty) {
if (these.head == elem) return true
these = these.tail
}
false
}

@deprecated("use `distinct` instead", "2.8.0")
def removeDuplicates: List[A] = distinct
Expand Down

0 comments on commit 80ba578

Please sign in to comment.