summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2017-02-07 17:27:58 -0800
committerGitHub <noreply@github.com>2017-02-07 17:27:58 -0800
commit40236b0378c597858d666beb4d38977b520df9e7 (patch)
tree18574ef3050debd6c09bf73da509bb06125b3250 /src/library
parent575c342039475d3c319487da81df5654ecf1127d (diff)
parent409f84d29f1dfae112a024d90aeb187248d48a3c (diff)
downloadscala-40236b0378c597858d666beb4d38977b520df9e7.tar.gz
scala-40236b0378c597858d666beb4d38977b520df9e7.tar.bz2
scala-40236b0378c597858d666beb4d38977b520df9e7.zip
Merge pull request #5579 from edmundnoble/queue-concat
Improve Queue.++ when building another Queue
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/immutable/Queue.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala
index 1dd0d7683a..240b5c899e 100644
--- a/src/library/scala/collection/immutable/Queue.scala
+++ b/src/library/scala/collection/immutable/Queue.scala
@@ -106,6 +106,15 @@ sealed class Queue[+A] protected(protected val in: List[A], protected val out: L
case _ => super.:+(elem)(bf)
}
+ override def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Queue[A], B, That]): That = {
+ if (bf eq Queue.ReusableCBF) {
+ val thatQueue = that.asInstanceOf[Queue[B]]
+ new Queue[B](thatQueue.in ++ (thatQueue.out reverse_::: this.in), this.out).asInstanceOf[That]
+ } else {
+ super.++(that)(bf)
+ }
+ }
+
/** Creates a new queue with element added at the end
* of the old queue.
*