Safronov Maxim created COLLECTIONS-878:
------------------------------------------

             Summary: Wrong capacity calculation leads to extra resize in 
MapUtils.invertMap
                 Key: COLLECTIONS-878
                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-878
             Project: Commons Collections
          Issue Type: Improvement
          Components: Map
         Environment: Doesn't matter
            Reporter: Safronov Maxim


MapUtils.invertMap create map with the same size via HashMap constructor with 
wrong capacity parameter. The capacity must be calculated as in new static 
factory method HashMap.newHashMap (since 19). Old size must be divided to load 
factor, in our case DEFAULT_LOAD_FACTOR 0.75 that casted to double. Otherwise 
we have 50% probability that our map will be extra resized during insertion of 
inverted entries. Expensive operation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to