File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
library/src/scala/collection/immutable Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -556,6 +556,15 @@ sealed abstract class List[+A]
556
556
result
557
557
}
558
558
559
+ override def partition (p : A => Boolean ): (List [A ], List [A ]) = {
560
+ if (isEmpty) List .TupleOfNil
561
+ else super .partition(p) match {
562
+ case (Nil , xs) => (Nil , this )
563
+ case (xs, Nil ) => (this , Nil )
564
+ case pair => pair
565
+ }
566
+ }
567
+
559
568
final override def toList : List [A ] = this
560
569
561
570
// Override for performance
@@ -610,6 +619,7 @@ case object Nil extends List[Nothing] {
610
619
*/
611
620
@ SerialVersionUID (3L )
612
621
object List extends StrictOptimizedSeqFactory [List ] {
622
+ private val TupleOfNil = (Nil , Nil )
613
623
614
624
def from [B ](coll : collection.IterableOnce [B ]): List [B ] = coll match {
615
625
case coll : List [B ] => coll
You can’t perform that action at this time.
0 commit comments