commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (JIRA)" <>
Subject [jira] [Commented] (COLLECTIONS-602) Improve efficiency of DefaultedMap.get
Date Sun, 21 May 2017 05:14:04 GMT


Bruno P. Kinoshita commented on COLLECTIONS-602:

For general information on how to contribute, see [this page|].

Commons Collections is still using Subversion for code management, this is the repository

If you are comfortable with Subversion, you can check out that repository, make your changes,
and follow the information in the first link to create a JIRA ticket, and a patch to attach
to the ticket with your changes.

If you are more comfortable or prefer to use Git, you can fork,
make all the changes in your own forked repository, and then [submit a pull request|].

A committer will review your patch or pull request, and either ask for feedback or changes,
and then merge it (-:

Hope that helps

> Improve efficiency of DefaultedMap.get
> --------------------------------------
>                 Key: COLLECTIONS-602
>                 URL:
>             Project: Commons Collections
>          Issue Type: Bug
>            Reporter: John Mark
>              Labels: help-wanted
> The current implementation of {{}}
is inefficient since it always require two map lookups. There is no need to check map.containsKey()
every time. I would suggest implementing this method similar to the way that Java 8 does with
{{Map.getOrDefault()}}. My proposed implementation would be something like this:
> {code}
> public V get(final Object key) {
>     V v;
>     return ((v = map.get(key) != null) || map.containsKey(key)) ? v : value.transform((K)
> }
> {code}
> It can be further optimized to not even call map.containsKey() if map is known to not
contain null values.

This message was sent by Atlassian JIRA

View raw message