Skip to content

Commit 2133b3f

Browse files
committed
review feedback
1 parent 9a9f052 commit 2133b3f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

compat/src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,15 @@ private abstract class PreservingBuilder[A, C <: TraversableOnce[A]] extends m.B
3434
ruined = true
3535
}
3636

37-
override def ++=(elems: TraversableOnce[A]): this.type =
38-
elems match {
39-
case ct(ca) if collection == null && !ruined =>
40-
collection = ca
41-
this
37+
override def ++=(elems: TraversableOnce[A]): this.type = {
38+
(if (collection == null && !ruined) ct.unapply(elems) else None) match {
39+
case Some(c) => collection = c
4240
case _ =>
4341
ruin()
4442
that ++= elems
45-
this
4643
}
44+
this
45+
}
4746

4847
def +=(elem: A): this.type = {
4948
ruin()
@@ -53,8 +52,10 @@ private abstract class PreservingBuilder[A, C <: TraversableOnce[A]] extends m.B
5352

5453
def clear(): Unit = {
5554
collection = null.asInstanceOf[C]
56-
if (ruined) that.clear()
57-
ruined = false
55+
if (ruined) {
56+
that.clear()
57+
ruined = false
58+
}
5859
}
5960

6061
def result(): C = if (collection == null) that.result() else collection

0 commit comments

Comments
 (0)