summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/List.scala
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2014-06-27 20:30:33 -0700
committerRex Kerr <ichoran@gmail.com>2014-06-27 20:30:33 -0700
commitff43de9f8f9e0e9fef55a825dfb067bdc61b90fc (patch)
tree2b9daf10918cc64e20c0a5edbfc6be2b47ff17e5 /src/library/scala/collection/immutable/List.scala
parentfbfce33cb03bc2b41dd0f46fa9f4630036b4f2ca (diff)
downloadscala-ff43de9f8f9e0e9fef55a825dfb067bdc61b90fc.tar.gz
scala-ff43de9f8f9e0e9fef55a825dfb067bdc61b90fc.tar.bz2
scala-ff43de9f8f9e0e9fef55a825dfb067bdc61b90fc.zip
SI-8335 List.++ avoidably burns memory
Changed to check the identity of the CanBuildFrom instead of the identity of the generated builder to shortcut building. Should reduce memory churn on ++ a little.
Diffstat (limited to 'src/library/scala/collection/immutable/List.scala')
-rw-r--r--src/library/scala/collection/immutable/List.scala6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 930e13a9d3..aa9dec2761 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -190,11 +190,9 @@ sealed abstract class List[+A] extends AbstractSeq[A]
// Overridden methods from IterableLike and SeqLike or overloaded variants of such methods
- override def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[List[A], B, That]): That = {
- val b = bf(this)
- if (b.isInstanceOf[ListBuffer[_]]) (this ::: that.seq.toList).asInstanceOf[That]
+ override def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[List[A], B, That]): That =
+ if (bf eq List.ReusableCBF) (this ::: that.seq.toList).asInstanceOf[That]
else super.++(that)
- }
override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[List[A], B, That]): That = bf match {
case _: List.GenericCanBuildFrom[_] => (elem :: this).asInstanceOf[That]