avoid boxing Comparator.comparings

This commit is contained in:
Max Weber
2021-11-14 13:10:26 -07:00
committed by Adam
parent 13ecfc0a9e
commit 081a30056c
12 changed files with 22 additions and 20 deletions

View File

@@ -65,13 +65,13 @@ public class RectangleUnion
boolean trace = log.isTraceEnabled();
// Sort all of the rectangles so they are ordered by their left edge
lefts.sort(Comparator.comparing(Rectangle::getX1));
lefts.sort(Comparator.comparingInt(Rectangle::getX1));
// Again, but for the right edge
// this should be relatively fast if the rectangles are similar sizes because timsort deals with partially
// presorted data well
List<Rectangle> rights = new ArrayList<>(lefts);
rights.sort(Comparator.comparing(Rectangle::getX2));
rights.sort(Comparator.comparingInt(Rectangle::getX2));
// ranges of our scan line with how many rectangles it is occluding
Segments segments = new Segments();