RenderDataPointReducingList GC optimization attempt

This commit is contained in:
James Seibel
2026-05-30 11:20:03 -05:00
parent ad9092c45c
commit ca4d6f158a
@@ -479,25 +479,21 @@ public class RenderDataPointReducingList extends AbstractPhantomArrayList
@VisibleForTesting @VisibleForTesting
public void sortBySize(int size) public void sortBySize(int size)
{ {
ShortArrayList array = this.sortingArray;
it.unimi.dsi.fastutil.Arrays.quickSort( it.unimi.dsi.fastutil.Arrays.quickSort(
0, 0, size,
size, this::sortBySizeComparator,
// comparator this::sortBySizeSwapper
(int index1, int index2) ->
{
return Integer.compare(
this.getSize(this.getSortingIndex(index1)),
this.getSize(this.getSortingIndex(index2))
);
},
// swapper
(int index1, int index2) ->
{
ShortArrays.swap(array.elements(), index1, index2);
}
); );
} }
// class methods to try reducing GC pressure vs in-line lambdas
private int sortBySizeComparator(int index1, int index2)
{
return Integer.compare(
this.getSize(this.getSortingIndex(index1)),
this.getSize(this.getSortingIndex(index2))
);
}
private void sortBySizeSwapper(int index1, int index2) { ShortArrays.swap(this.sortingArray.elements(), index1, index2); }
/** /**
* sorts our {@link #sortingArray} in order of lowest-to-highest, * sorts our {@link #sortingArray} in order of lowest-to-highest,
@@ -506,25 +502,21 @@ public class RenderDataPointReducingList extends AbstractPhantomArrayList
@VisibleForTesting @VisibleForTesting
public void sortByPosition(int size) public void sortByPosition(int size)
{ {
ShortArrayList array = this.sortingArray;
it.unimi.dsi.fastutil.Arrays.quickSort( it.unimi.dsi.fastutil.Arrays.quickSort(
0, 0, size,
size, this::sortByPositionComparator,
// comparator this::sortByPositionSwapper
(int index1, int index2) ->
{
return Integer.compare(
this.getMinY(this.getSortingIndex(index1)),
this.getMinY(this.getSortingIndex(index2))
);
},
// swapper
(int index1, int index2) ->
{
ShortArrays.swap(array.elements(), index1, index2);
}
); );
} }
// class methods to try reducing GC pressure vs in-line lambdas
private int sortByPositionComparator(int index1, int index2)
{
return Integer.compare(
this.getMinY(this.getSortingIndex(index1)),
this.getMinY(this.getSortingIndex(index2))
);
}
private void sortByPositionSwapper(int index1, int index2) { ShortArrays.swap(this.sortingArray.elements(), index1, index2); }
/** /**
* moves the smaller node to the correct position in the list, * moves the smaller node to the correct position in the list,