diff options
author | Rui Gonçalves <ruippeixotog@gmail.com> | 2016-04-17 17:51:17 +0100 |
---|---|---|
committer | Rui Gonçalves <ruippeixotog@gmail.com> | 2016-05-17 10:55:16 +0100 |
commit | fe6886eb0ec9c02fa666e9e7af09bab92b985d05 (patch) | |
tree | aadd0a52ec583ff7fbd45ec95e611781adeee291 /test/files/jvm | |
parent | 4c4c5e61a3b24e44247380eaf0519ee46036431a (diff) | |
download | scala-fe6886eb0ec9c02fa666e9e7af09bab92b985d05.tar.gz scala-fe6886eb0ec9c02fa666e9e7af09bab92b985d05.tar.bz2 scala-fe6886eb0ec9c02fa666e9e7af09bab92b985d05.zip |
Improve performance and behavior of ListMap and ListSet
Makes the immutable `ListMap` and `ListSet` collections more alike one another, both in their semantics and in their performance.
In terms of semantics, makes the `ListSet` iterator return the elements in their insertion order, as `ListMap` already does. While, as mentioned in SI-8985, `ListMap` and `ListSet` doesn't seem to make any guarantees in terms of iteration order, I believe users expect `ListSet` and `ListMap` to behave in the same way, particularly when they are implemented in the exact same way.
In terms of performance, `ListSet` has a custom builder that avoids creation in O(N^2) time. However, this significantly reduces its performance in the creation of small sets, as its requires the instantiation and usage of an auxilliary HashSet. As `ListMap` and `ListSet` are only suitable for small sizes do to their performance characteristics, the builder is removed, the default `SetBuilder` being used instead.
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/serialization-new.check | 4 | ||||
-rw-r--r-- | test/files/jvm/serialization.check | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check index cb26446f40..91248320d4 100644 --- a/test/files/jvm/serialization-new.check +++ b/test/files/jvm/serialization-new.check @@ -89,8 +89,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 = ListSet(5, 3) -y = ListSet(5, 3) +x = ListSet(3, 5) +y = ListSet(3, 5) x equals y: true, y equals x: true x = Queue(a, b, c) diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index cb26446f40..91248320d4 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -89,8 +89,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 = ListSet(5, 3) -y = ListSet(5, 3) +x = ListSet(3, 5) +y = ListSet(3, 5) x equals y: true, y equals x: true x = Queue(a, b, c) |