Skip to content

SI-7981 toSeq on immutable Map and Set return ArrayBuffer#4175

Merged
lrytz merged 1 commit intoscala:2.12.xfrom
Ichoran:issue/7981
Dec 4, 2014
Merged

SI-7981 toSeq on immutable Map and Set return ArrayBuffer#4175
lrytz merged 1 commit intoscala:2.12.xfrom
Ichoran:issue/7981

Conversation

@Ichoran
Copy link
Contributor

@Ichoran Ichoran commented Nov 30, 2014

Switched to Vector for the default MapLike/SetLike, then back again in mutable.MapLike/mutable.SetLike.

Preliminary performance testing indicates an across-the-board improvement due to cutting out a great deal of indirection. In the case of empty immutable maps or sets, the improvement is enormous: it quickly returns Vector.empty instead of jumping through all sorts of hoops to eventually create an empty ArrayBuffer.

One possible downside is that Vector is pretty memory-hungry for small collections. Need to evalute this; rather than abandoning this change, it's probably better to make Vector smarter about small collections.

Switched to `Vector` for the default `MapLike`/`SetLike`, then back again in `mutable.MapLike`/`mutable.SetLike`.

Preliminary performance testing indicates an across-the-board improvement due to cutting out a great deal of indirection.  In the case of empty immutable maps or sets, the improvement is enormous: it quickly returns Vector.empty instead of jumping through all sorts of hoops to eventually create an empty `ArrayBuffer`.

One possible downside is that `Vector` is pretty memory-hungry for small collections.  Need to evalute this; rather than abandoning this change, it's probably better to make `Vector` smarter about small collections.

Also fixed test with literal "ArrayBuffer" in output (`s/ArrayBuffer/Vector/g`).
@lrytz
Copy link
Member

lrytz commented Dec 4, 2014

LGTM!

lrytz added a commit that referenced this pull request Dec 4, 2014
SI-7981  toSeq on immutable Map and Set return ArrayBuffer
@lrytz lrytz merged commit f13fc65 into scala:2.12.x Dec 4, 2014
@adriaanm adriaanm added the 2.12 label Oct 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants