The previous implementation uses ArrayList for storing resolved resources and ArrayList has O(n) time complexity for the contains operation. By switching to the HashSet for storing resolved resources we improve the time complexity of this operation to be O(1).
Comment From: rstoyanchev
Doesn't this change the order of resources and eliminate duplicates both of which could be significant? Are you seeing an actual performance hotspot with this in some scenario?
Comment From: shevtsiv
Doesn't this changes the order of resources and eliminate duplicates both of which could be significant? Are you seeing an actual performance hotspot with this in some scenario?
I don't have any specific performance metrics, just found a spot in the scope of some bugfix, and decided to suggest an improvement. You are right, this may change the order of the resources, but the elimination should be done right as the initial code also checks for duplicates. If the ordering could not be fixed with something like LinkedHashSet, then I think this PR can be closed, thanks!
Comment From: rstoyanchev
Thanks, I've updated it to use LinkedHashSet
.