garydgregory commented on code in PR #755:
URL: 
https://github.com/apache/commons-collections/pull/755#discussion_r4542638324


##########
src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java:
##########
@@ -288,26 +330,34 @@ public int size() {
     }
 
     /**
-     * Updates the current iterator field to ensure that the current Iterator 
is
-     * not exhausted
+     * Updates the current iterator field to ensure that the current Iterator 
is not exhausted.
+     * Nested instances of this class are traversed iteratively; subclasses 
are invoked normally to preserve their overrides.
      */
     protected void updateCurrentIterator() {
-        if (currentIterator == null) {
-            if (iteratorQueue.isEmpty()) {
-                currentIterator = EmptyIterator.<E>emptyIterator();
+        final Deque<IteratorChain<? extends E>> parents = new ArrayDeque<>();

Review Comment:
   Addressed. The parent deque and identity set are now allocated only when 
descending into an uncached nested chain. Completed children are removed from 
the active set during unwinding, so shared acyclic children remain valid. Flat 
traversal requires neither allocation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to