elharo opened a new issue, #131: URL: https://github.com/apache/maven-dependency-tree/issues/131
## Summary `SerializingDependencyNodeVisitor` re-derives ancestor “is last sibling” state on every node by walking back up the tree, making output linear in node count only for shallow graphs and roughly cubic for deep chains. ## Affected code `src/main/java/org/apache/maven/shared/dependency/graph/traversal/SerializingDependencyNodeVisitor.java` - `indent(...)` calls `isLast(node, i)` for every ancestor level: lines 161-169 - `isLast(node, i)` walks up `(depth - i)` parents each time: lines 202-212 - `isLast(node)` scans `siblings.indexOf(node)`: lines 177-193 ## Impact Per-node work is ~depth², so a deep chain of N nodes costs ~N³ pointer walks (a 10k-deep chain is on the order of 10¹² steps). Wide trees degrade to quadratic via `indexOf` on long sibling lists. This is the dominant cost when printing `mvn dependency:tree`. ## Suggested fix Maintain the ancestor fill-indent state incrementally during the pre-order walk (push/pop “is last” per level) instead of recomputing it per node, and avoid `siblings.indexOf` by tracking the last-visited sibling index. -- 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]
