9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 10:29:13 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0283-optimize-SimpleBitStorage-object-layout.patch
Dreeam f5b95a6716 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939)
PaperMC/Paper@1922be90 Update custom tags (#12183)
PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009)
PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949)
PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992)
PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974)
PaperMC/Paper@42b653b1 Expose more argument types (#12665)
PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010)
PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996)
PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
2025-08-25 15:52:00 -04:00

42 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
Date: Sat, 9 Aug 2025 14:55:00 +0900
Subject: [PATCH] optimize SimpleBitStorage object layout
diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java
index 8091f0c0a536047ead4966e70785962e87faad9a..8aec073db74a4d0a21c8a423586d108c6add9ad5 100644
--- a/net/minecraft/util/SimpleBitStorage.java
+++ b/net/minecraft/util/SimpleBitStorage.java
@@ -204,8 +204,8 @@ public class SimpleBitStorage implements BitStorage {
private final long mask;
private final int size;
private final int valuesPerLong;
- private final int divideMul; private final long divideMulUnsigned; // Paper - Perf: Optimize SimpleBitStorage; referenced in b(int) with 2 Integer.toUnsignedLong calls
- private final int divideAdd; private final long divideAddUnsigned; // Paper - Perf: Optimize SimpleBitStorage
+ private final int divideMul; /*private final long divideMulUnsigned;*/ // Paper - Perf: Optimize SimpleBitStorage; referenced in b(int) with 2 Integer.toUnsignedLong calls // Leaf - optimize SimpleBitStorage object layout
+ private final int divideAdd; /*private final long divideAddUnsigned;*/ // Paper - Perf: Optimize SimpleBitStorage // Leaf - optimize SimpleBitStorage object layout
private final int divideShift;
// Paper start - optimise bitstorage read/write operations
@@ -262,8 +262,8 @@ public class SimpleBitStorage implements BitStorage {
this.mask = (1L << bits) - 1L;
this.valuesPerLong = (char)(64 / bits);
int i = 3 * (this.valuesPerLong - 1);
- this.divideMul = MAGIC[i + 0]; this.divideMulUnsigned = Integer.toUnsignedLong(this.divideMul); // Paper - Perf: Optimize SimpleBitStorage
- this.divideAdd = MAGIC[i + 1]; this.divideAddUnsigned = Integer.toUnsignedLong(this.divideAdd); // Paper - Perf: Optimize SimpleBitStorage
+ this.divideMul = MAGIC[i + 0]; /*this.divideMulUnsigned = Integer.toUnsignedLong(this.divideMul);*/ // Paper - Perf: Optimize SimpleBitStorage // Leaf - optimize SimpleBitStorage object layout
+ this.divideAdd = MAGIC[i + 1]; /*this.divideAddUnsigned = Integer.toUnsignedLong(this.divideAdd);*/ // Paper - Perf: Optimize SimpleBitStorage // Leaf - optimize SimpleBitStorage object layout
this.divideShift = MAGIC[i + 2];
int i1 = (size + this.valuesPerLong - 1) / this.valuesPerLong;
if (data != null) {
@@ -285,7 +285,7 @@ public class SimpleBitStorage implements BitStorage {
}
private int cellIndex(int index) {
- return (int)(index * this.divideMulUnsigned + this.divideAddUnsigned >> 32 >> this.divideShift); // Paper - Perf: Optimize SimpleBitStorage
+ return (int)(index * Integer.toUnsignedLong(this.divideMul) + Integer.toUnsignedLong(this.divideAdd) >> 32 >> this.divideShift); // Paper - Perf: Optimize SimpleBitStorage // Leaf - optimize SimpleBitStorage object layout
}
@Override