mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 18:39:23 +00:00
Current implementation of OP lock is not an appropriate solution to prevent plugins that contain backdoor or malicious code. There are many ways to bypass this check to manipulate the OP list or permissions. The best way to prevent this kind of grief is to get plugins from valid and trustworthy places.
48 lines
2.5 KiB
Diff
48 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: hayanesuru <hayanesuru@outlook.jp>
|
|
Date: Sat, 9 Aug 2025 14:59:34 +0900
|
|
Subject: [PATCH] optimize PalettedContainer#get
|
|
|
|
|
|
diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
index 49220967392331dd9928a539da6e6052b007e318..dd26ee1c377709d77709d449e98694d047afaa09 100644
|
|
--- a/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
+++ b/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
@@ -48,6 +48,18 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
|
private final PalettedContainer.Strategy strategy;
|
|
//private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); // Paper - unused
|
|
|
|
+ // Leaf start - optimize PalettedContainer#get
|
|
+ private static final java.lang.invoke.VarHandle DATA_HANDLE;
|
|
+ static {
|
|
+ try {
|
|
+ DATA_HANDLE = java.lang.invoke.MethodHandles.lookup()
|
|
+ .findVarHandle(PalettedContainer.class, "data", PalettedContainer.Data.class);
|
|
+ } catch (ReflectiveOperationException e) {
|
|
+ throw new ExceptionInInitializerError(e);
|
|
+ }
|
|
+ }
|
|
+ // Leaf end - optimize PalettedContainer#get
|
|
+
|
|
public void acquire() {
|
|
// this.threadingDetector.checkAndLock(); // Paper - disable this - use proper synchronization
|
|
}
|
|
@@ -104,7 +116,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
|
}
|
|
|
|
private T readPalette(final PalettedContainer.Data<T> data, final int paletteIdx) {
|
|
- final T[] palette = ((ca.spottedleaf.moonrise.patches.fast_palette.FastPaletteData<T>)(Object)data).moonrise$getPalette();
|
|
+ final T[] palette = data.moonrise$getPalette(); // Leaf - optimize PalettedContainer#get - remove type cast
|
|
if (palette == null) {
|
|
return this.readPaletteSlow(data, paletteIdx);
|
|
}
|
|
@@ -268,7 +280,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
|
|
|
public T get(int index) { // Paper - public
|
|
// Paper start - optimise palette reads
|
|
- final PalettedContainer.Data<T> data = this.data;
|
|
+ final PalettedContainer.Data<T> data = (PalettedContainer.Data<T>) DATA_HANDLE.getAcquire(this); // Leaf - optimize PalettedContainer#get
|
|
return this.readPalette(data, data.storage.get(index));
|
|
// Paper end - optimise palette reads
|
|
}
|