Skip to content

Commit d8fe39c

Browse files
authored
Avoid primitive boxing caused by enhanced for-loops in translucency sorting (#3135)
1 parent d91d280 commit d8fe39c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/bsp_tree/InnerPartitionBSPNode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ static BSPNode build(BSPWorkspace workspace, IntArrayList indexes, int depth, BS
245245

246246
// collect all the geometry's start and end points in this direction
247247
points.clear();
248-
for (int quadIndex : indexes) {
248+
for (int i = 0, size = indexes.size(); i < size; i++) {
249+
int quadIndex = indexes.getInt(i);
249250
var quad = workspace.quads[quadIndex];
250251
var extents = quad.getExtents();
251252
var posExtent = extents[axis];
@@ -288,7 +289,8 @@ static BSPNode build(BSPWorkspace workspace, IntArrayList indexes, int depth, BS
288289
IntArrayList quadsBefore = null;
289290
IntArrayList quadsOn = null;
290291
int thickness = 0;
291-
for (long point : points) {
292+
for (int i = 0, size = points.size(); i < size; i++) {
293+
long point = points.getLong(i);
292294
switch (decodeType(point)) {
293295
case INTERVAL_START -> {
294296
// unless at the start, flush if there's a gap

common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/trigger/NormalPlanes.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public void prepareIntegration() {
5757
var size = this.relativeDistancesSet.size();
5858
this.relativeDistances = new float[this.relativeDistancesSet.size()];
5959
int i = 0;
60-
for (float relDistance : this.relativeDistancesSet) {
60+
for (var it = this.relativeDistancesSet.iterator(); it.hasNext(); ) {
61+
float relDistance = it.nextFloat();
6162
this.relativeDistances[i++] = relDistance;
6263

6364
long distanceBits = Double.doubleToLongBits(relDistance);

0 commit comments

Comments
 (0)