diff options
author | Paul Phillips <paulp@improving.org> | 2010-09-17 05:03:43 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-09-17 05:03:43 +0000 |
commit | a4e163d2627f332f4c05fcf729b8bb5e843b0ed1 (patch) | |
tree | f3f2d9d4fd69bf0dd9e198b4082554f1f5855a27 /test | |
parent | 99fb2b420f2fbf0eca5a98d0e52f8c6b580cd18f (diff) | |
download | scala-a4e163d2627f332f4c05fcf729b8bb5e843b0ed1.tar.gz scala-a4e163d2627f332f4c05fcf729b8bb5e843b0ed1.tar.bz2 scala-a4e163d2627f332f4c05fcf729b8bb5e843b0ed1.zip |
Some tweaks to ListSet to make it less patholog...
Some tweaks to ListSet to make it less pathological in its outlook. We
can see some modest improvements in run time and answer quality via the
enclosed test case:
// with this patch: 2.250s elapsed, assertions pass.
// without this patch: 51.441s elapsed, and it's
a mercy killing: java.lang.StackOverflowError at
scala.collection.immutable.ListSet$Node.contains(ListSet.scala:117) at
scala.collection.immutable.ListSet$Node.contains(ListSet.scala:117)
Closes #3822, review by community.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/serialization.check | 4 | ||||
-rw-r--r-- | test/files/run/bug3822.scala | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index 3f095cb51e..9397d3f7e9 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -93,8 +93,8 @@ x = Map(buffers -> 20, layers -> 2, title -> 3) y = Map(buffers -> 20, layers -> 2, title -> 3) x equals y: true, y equals x: true -x = Set(5, 3) -y = Set(5, 3) +x = ListSet(5, 3) +y = ListSet(5, 3) x equals y: true, y equals x: true x = Queue(a, b, c) diff --git a/test/files/run/bug3822.scala b/test/files/run/bug3822.scala new file mode 100644 index 0000000000..7401ecbde2 --- /dev/null +++ b/test/files/run/bug3822.scala @@ -0,0 +1,13 @@ +import scala.collection.{ mutable, immutable, generic } +import immutable.ListSet + +object Test { + def main(args: Array[String]): Unit = { + val xs = ListSet(-100000 to 100001: _*) + + assert(xs.size == 200002) + assert(xs.sum == 100001) + } +} + + |