Part of #118145. As noted in a comment, this algorithm has O(n^2) runtime which is quite bad. Ideally we would be able to look into a better solution at some point, but I just refactored the existing algorithm here.
Part of #118145. As noted in a comment, this algorithm has O(n^2) runtime which is quite bad. Ideally we would be able to look into a better solution at some point, but I just refactored the existing algorithm here.