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

Joerg Budischewski commented on COLLECTIONS-722:
------------------------------------------------

The attached [^chainedIterator-CheckForSelf-Patch-Suggestion.txt] would solve 
the OP's
problem by checking, whether
the first iterator instance is an IteratorChain, and if yes,
add the additional iterators instead of creating a chained new one.

This "fix" is very "specific", e.g. it fails
when the IteratorChain instance would be passed as n-th argument (n > 1), which
can be addressed by adding IteratorChain.prepend() method and using
prepend()/add() on the first IteratorChain in the given list.

However that won't improve things in case the iterators get wrapped again by 
something else.

So I am not sure whether it would be worth it. Would a PR get accepted when it
follows this sketched out solution ?

> IteratorUtils.chainedIterator() Performance Degrades
> ----------------------------------------------------
>
>                 Key: COLLECTIONS-722
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-722
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 4.1
>            Reporter: E P
>            Priority: Major
>         Attachments: IteratorUtilsTest.java, 
> chainedIterator-CheckForSelf-Patch-Suggestion.txt
>
>
> IteratorUtils.chainedIterator() performance degrades when chaining iterators 
> with chained iterators.   The slowdown appears to be exponential, based upon 
> the number of chains created.  The attached test shows the issue.  
> As a reference, the same test below works as expected using Google's Guava 
> Iterator.concat() functionality.   It is possible I am misusing the API, but 
> the javadoc did not indicate as much.
>  



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

Reply via email to