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

Jan-Kees van Andel commented on MYFACES-3130:
---------------------------------------------

One comment. Since we know some of the collections where the performance gain 
is substantial, I suggest to put some "instanceof ArrayList" checks in the code 
and log a warning that an ArrayList is more suitable.

I know it's not strictly necessary, but at least it warns users for bad 
performance.

About the concurrentmodificationexception, why not just do a list.toArray() and 
then loop over that array? It might even improve performance (not tested)...

> [PERF] Avoid unnecessary AbstractList$Itr instances
> ---------------------------------------------------
>
>                 Key: MYFACES-3130
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3130
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-314
>         Environment: myfaces core trunk
>            Reporter: Martin Kočí
>         Attachments: MYFACES-3130-example.patch
>
>
> Similar issue: MYFACES-3129
> loop from java 5:
> for (Object object: objects)
> creates new instance of AbstractList$Itr, if objects are instance of 
> ArrayList. 
> Similar situation is with explicit .iterator() call.
> In my testcases, it is about ~ 100 000 instances per request/response. 
> Creation itself is cheap, but triggers GC lately.
> I suggest to use old index-style for (i = 0; i < childCount;   i++) if 
> possible. Are there any rawbacks of index-based iteration? 
> Children is List and as implementation detail we  know that it is instance of 
> ArrayList.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to