Skip to content

Create new trait MapBuilder extending Builder, which adds non-allocating addOne method #11297

Open
@joshlemer

Description

@joshlemer

Needlessly creating tuples has a major performance impact when building maps. The standard library to some extent routes around this by accessing package-private addOne(key, value) methods on some builders of maps that happen to expose it (HashMapBuilder for instance).

I think that users of Scala who care a lot about performance might want to use this technique as well.

Also, users implementing their own high-performance composite data structures may get use out of having a MapBuilder#get(key): Option[V] or MapBuilder#getOrElse(key, value): Value, see #11296 for an example use-case within the standard library.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions