-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
More flexible MapSplitter API #3491
Comments
Can you provide a little more context about the problem you're looking to solve with a mutable result parameter? I see that you want to modify the result by adding default values and want to avoid adding garbage by doing things like copying the result of One thing you can consider in the meantime is to unpack the Splitter and manually split the entry set:
|
A few months ago, we decided to add Nor did we explicitly discuss a |
Also, it would be great to split into ImmutableMap. |
Unfortunately that's not possible because it would create a circular dependency between |
I name the issue vaguely as I don't want to force any particular change. I will describe my use case and then one possible solution.
Currently
MapSplitter
has only one method:and returns immutable collection.
My use case is that I would like to change the resulting collection, e.g. by appending some default values for missing entries. I also want to reduce GC pressure and not create unnecessary collections along the way.
One solution that comes to mind is to provide the map to be used for storing the result:
Instead of map it can be a factory argument:
Additionally both approaches would allow for hash map pooling if required. I can work on a PR if this API addition makes sense.
The text was updated successfully, but these errors were encountered: