Skip to content

Conversation

@pdelagrave
Copy link
Contributor

When using diff --jar on large JARs (~500 000 members) the process would take hours to finish.

referencedMembers -= declaredMembers is where all the time was spent.
This actually does AbstractSet#removeAll() which calls declaredMembers.contains() for each element of referencedMembers. List.contains() is O(n) vs O(1) for Set.contains(), so the whole operation would be O(n^2) instead of O(n).

@JakeWharton JakeWharton enabled auto-merge (squash) December 4, 2025 15:45
@JakeWharton
Copy link
Owner

Nice find. Thanks!

@JakeWharton JakeWharton merged commit aba159e into JakeWharton:trunk Dec 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants