diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2013-12-10 00:47:59 +0100 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2013-12-11 21:50:09 +0100 |
commit | f0f0a5e7813501d985174d3c5573c34c8a7608c6 (patch) | |
tree | eb3d6cd0f03ef7c5c579a53c5f7445ba5b1b9c2c /test/files/run | |
parent | b345b42cac64aa97e3bbcc6f14ef8f08214ab56f (diff) | |
download | scala-f0f0a5e7813501d985174d3c5573c34c8a7608c6.tar.gz scala-f0f0a5e7813501d985174d3c5573c34c8a7608c6.tar.bz2 scala-f0f0a5e7813501d985174d3c5573c34c8a7608c6.zip |
SI-8059 Override immutable.Queue#{+:,:+} for performance
Without those overrides, all elements are unnecessarily copied.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/iq.check | 4 | ||||
-rw-r--r-- | test/files/run/iq.scala | 17 |
2 files changed, 18 insertions, 3 deletions
diff --git a/test/files/run/iq.check b/test/files/run/iq.check index 81114ea181..311bf83ed4 100644 --- a/test/files/run/iq.check +++ b/test/files/run/iq.check @@ -1,4 +1,8 @@ Empty +q2: Queue(42, 0) +qa: Queue(42, 0) +qb: Queue(42, 0) +qc: Queue(42, 0) Head: 42 q5: Queue(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) q5[5]: 5 diff --git a/test/files/run/iq.scala b/test/files/run/iq.scala index 31859cf867..1eb1d40e37 100644 --- a/test/files/run/iq.scala +++ b/test/files/run/iq.scala @@ -16,10 +16,21 @@ object iq { Console.println("Empty") } - /* Test infix enqueing. */ - //val q2 = q + 42 + 0 // deprecated + /* Test enqueing. */ val q2 = q.enqueue(42).enqueue(0) + val qa = q :+ 42 :+ 0 + assert(q2 == qa) + + val qb = 42 +: 0 +: q + assert(q2 == qb) + val qc = 42 +: q :+ 0 + assert(q2 == qc) + Console.println("q2: " + q2) + Console.println("qa: " + qa) + Console.println("qb: " + qb) + Console.println("qc: " + qc) + /* Test is empty and dequeue. * Expected: Head: 42 */ @@ -37,7 +48,7 @@ object iq { /* Test sequence enqueing. */ val q5: Queue[Any] = q4.enqueue(List(1,2,3,4,5,6,7,8,9)) /* Test toString. - * Expected: Head: q5: Queue(0,1,2,3,4,5,6,7,8,9) + * Expected: q5: Queue(0,1,2,3,4,5,6,7,8,9) */ Console.println("q5: " + q5) /* Test apply |