[ 
https://issues.apache.org/jira/browse/CSV-184?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15331240#comment-15331240
 ] 

M. Steiger commented on CSV-184:
--------------------------------

I believe that passing a Map to the toMap() method makes sense, because it 
allows users to pass any implementation and most importantly, reuse a Map 
instance.

I see two shortcomings of the current implementation:

a) HashMap does not preserve insertion order
b) A new instance is created for every record
c) Iteration is slow (at least relatively speaking) since entries are unlinked

Imho, it could be improved by 

a) using a LinkedHashMap
b) reusing the Map instance across the entire iteration (and protecting the 
returned instance by Collections.unmodifiableMap )
c) Alternatively allow users to provide a Map instance


> CSVRecord toMap Method(LoadFactor for HashMap)
> ----------------------------------------------
>
>                 Key: CSV-184
>                 URL: https://issues.apache.org/jira/browse/CSV-184
>             Project: Commons CSV
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.4
>            Reporter: Gaurav Agarwal
>            Priority: Minor
>
> Set loadFactor for Hashmap Object to 1(Default : 0.75) as currently it will 
> always resize the map when we are putting entries in it.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to