summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/LinearSeqLike.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-12-23 03:52:03 -0800
committerPaul Phillips <paulp@improving.org>2011-12-30 23:41:52 -0800
commit82c793a438c7bd802daf96c8b2012f54fbd737ba (patch)
tree3bed6b8cc121a17e54529f312edcf6c2058453c4 /src/library/scala/collection/LinearSeqLike.scala
parent6150b589993fc58817d6d1d2e4326c8ff135a0ea (diff)
downloadscala-82c793a438c7bd802daf96c8b2012f54fbd737ba.tar.gz
scala-82c793a438c7bd802daf96c8b2012f54fbd737ba.tar.bz2
scala-82c793a438c7bd802daf96c8b2012f54fbd737ba.zip
More performance work.
Custom versions of collections which methods which operate on 2 or 3 collections. Eliminated most users of zip/zipped. Cleaned up the kinds checking code somewhat. Reduced the number of silent typechecks being performed at named argument sites.
Diffstat (limited to 'src/library/scala/collection/LinearSeqLike.scala')
-rw-r--r--src/library/scala/collection/LinearSeqLike.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/library/scala/collection/LinearSeqLike.scala b/src/library/scala/collection/LinearSeqLike.scala
index 75c1edac66..ceb980ff80 100644
--- a/src/library/scala/collection/LinearSeqLike.scala
+++ b/src/library/scala/collection/LinearSeqLike.scala
@@ -13,6 +13,7 @@ import generic._
import mutable.ListBuffer
import immutable.List
import scala.util.control.Breaks._
+import annotation.tailrec
/** A template trait for linear sequences of type `LinearSeq[A]`.
*
@@ -69,4 +70,9 @@ trait LinearSeqLike[+A, +Repr <: LinearSeqLike[A, Repr]] extends SeqLike[A, Repr
xs
}
}
+
+ @tailrec override final def corresponds[B](that: GenSeq[B])(p: (A,B) => Boolean): Boolean = {
+ if (this.isEmpty) that.isEmpty
+ else that.nonEmpty && p(head, that.head) && (tail corresponds that.tail)(p)
+ }
}