summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-12-17 08:55:52 +0000
committerPaul Phillips <paulp@improving.org>2010-12-17 08:55:52 +0000
commit4a442e98e3e8a5c851d30cf782d29be0afc156fa (patch)
tree4dd696eebf064b7d257a7152fb829565a62a3b6f /src
parent46a978e022b1bc3d1b77e8b5402db6d3ab6dd28f (diff)
downloadscala-4a442e98e3e8a5c851d30cf782d29be0afc156fa.tar.gz
scala-4a442e98e3e8a5c851d30cf782d29be0afc156fa.tar.bz2
scala-4a442e98e3e8a5c851d30cf782d29be0afc156fa.zip
Discovered bug in mapConserve introduced in r23...
Discovered bug in mapConserve introduced in r23038 when a tail recursive version was submitted. I am optimistic this is a player in recent performance degradation based on the timing of the commit and the fact that I was examining mapConserve because of info from my homemade profiler. (But it's late and I only just found it, so I'll be the last to know.) Review by odersky.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/immutable/List.scala4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 8c018912c2..f717d516aa 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -99,8 +99,6 @@ sealed abstract class List[+A] extends LinearSeq[A]
* Like `xs map f`, but returns `xs` unchanged if function
* `f` maps all elements to themselves (wrt eq).
*
- * Note: Unlike `map`, `mapConserve` is not tail-recursive.
- *
* @param f the function to apply to each element.
* @tparam B the element type of the returned collection.
* @return a list resulting from applying the given function
@@ -118,7 +116,7 @@ sealed abstract class List[+A] extends LinearSeq[A]
val head0 = pending.head
val head1 = f(head0)
- if (head1 == head0)
+ if (head1 eq head0.asInstanceOf[AnyRef])
loop(mapped, unchanged, pending.tail)
else {
val b = if (mapped eq null) new ListBuffer[B] else mapped