diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-04 04:54:24 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-04 04:54:24 +0000 |
commit | 69b9d9858e6127d021e083d336e9629c12173698 (patch) | |
tree | c8151e479d91f238449e24c41d2f4edb807cb947 /src | |
parent | f34c836cb67ed4c03b03218dff0a048466cbf13f (diff) | |
download | scala-69b9d9858e6127d021e083d336e9629c12173698.tar.gz scala-69b9d9858e6127d021e083d336e9629c12173698.tar.bz2 scala-69b9d9858e6127d021e083d336e9629c12173698.zip |
Hard to explain garbage led me to this innocent...
Hard to explain garbage led me to this innocent seeming change. Not that
innocent. A function like this should create no garbage:
final def f[T](xs: List[T], num: Int) {
if (num > 0) f(Nil ::: xs ::: Nil, num - 1)
}
Instead it was creating a lot. No review.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/immutable/List.scala | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 5446b25888..563f14eac6 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -75,6 +75,7 @@ sealed abstract class List[+A] extends LinearSeq[A] */ def :::[B >: A](prefix: List[B]): List[B] = if (isEmpty) prefix + else if (prefix.isEmpty) this else (new ListBuffer[B] ++= prefix).prependToList(this) /** Adds the elements of a given list in reverse order in front of this list. |