Micro alloc opts
This commit is contained in:
277
patches/server/0082-Micro-alloc-opts.patch
Normal file
277
patches/server/0082-Micro-alloc-opts.patch
Normal file
@@ -0,0 +1,277 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Etil <81570777+etil2jz@users.noreply.github.com>
|
||||
Date: Mon, 20 Dec 2021 00:53:51 +0100
|
||||
Subject: [PATCH] Micro alloc opts
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
||||
index c0d123bff1825366c30aadd3ad8a7fde68ef74e4..c1e4336cf40d3bc36b9de84a3e09c06e39891f4d 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
||||
@@ -68,6 +68,8 @@ import java.util.Set;
|
||||
import java.util.function.ToIntFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
+
|
||||
public class PaperCommand extends Command {
|
||||
private static final String BASE_PERM = "bukkit.command.paper.";
|
||||
private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "fixlight", "syncloadinfo", "dumpitem", "mobcaps", "playermobcaps").build();
|
||||
@@ -214,7 +216,7 @@ public class PaperCommand extends Command {
|
||||
case "version":
|
||||
Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
||||
if (ver != null) {
|
||||
- ver.execute(sender, commandLabel, new String[0]);
|
||||
+ ver.execute(sender, commandLabel, Constants.EMPTY_str_arr); // Mirai - micro alloc opts
|
||||
break;
|
||||
}
|
||||
// else - fall through to default
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java
|
||||
index 277cfd9d1e8fff5d9b5e534b75c3c5162d58b0b7..068ec8eee84ebfb18e1e29b2bbe3b2bbfe855bf5 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java
|
||||
@@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.GlobalPalette;
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
/**
|
||||
* @author Spottedleaf
|
||||
@@ -20,7 +21,7 @@ public final class IBlockDataList {
|
||||
this.map.defaultReturnValue(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
- private static final long[] EMPTY_LIST = new long[0];
|
||||
+ private static final long[] EMPTY_LIST = Constants.EMPTY_long_arr; // Mirai - micro alloc opts
|
||||
|
||||
private long[] byIndex = EMPTY_LIST;
|
||||
private int size;
|
||||
diff --git a/src/main/java/me/titaniumtown/Constants.java b/src/main/java/me/titaniumtown/Constants.java
|
||||
index 1080d62ed011f2ae1d951fd01881437edc0cbe27..a2997943ec920670364d518786f28af999cfcefb 100644
|
||||
--- a/src/main/java/me/titaniumtown/Constants.java
|
||||
+++ b/src/main/java/me/titaniumtown/Constants.java
|
||||
@@ -13,4 +13,10 @@ public final class Constants {
|
||||
public static final EquipmentSlot[] ALL_EquipmentSlot = EquipmentSlot.values();
|
||||
public static final int[] EMPTY_int_arr = new int[0];
|
||||
public static final int[] ZERO_int_arr = new int[]{0};
|
||||
+
|
||||
+ // Mirai start
|
||||
+ public static final String[] EMPTY_str_arr = new String[0];
|
||||
+ public static final long[] EMPTY_long_arr = new long[0];
|
||||
+ public static final byte[] EMPTY_byte_arr = new byte[0];
|
||||
+ // Mirai end
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/nbt/ByteArrayTag.java b/src/main/java/net/minecraft/nbt/ByteArrayTag.java
|
||||
index 3dd8a189c26f41759c59c3b9d0e5282038989a9f..9531ec2043024f9e312cc9f0f338c2df5fc94aa6 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/ByteArrayTag.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/ByteArrayTag.java
|
||||
@@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
public class ByteArrayTag extends CollectionTag<ByteTag> {
|
||||
|
||||
@@ -170,7 +171,7 @@ public class ByteArrayTag extends CollectionTag<ByteTag> {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
- this.data = new byte[0];
|
||||
+ this.data = Constants.EMPTY_byte_arr; // Mirai - micro alloc opts
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||
index 210f81e380cb38c2d5d69849e593d2fdb54e8856..90da703cc948ac919c957df5098655c9c4df8dee 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||
@@ -18,6 +18,7 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
import net.minecraft.ReportedException;
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
public class CompoundTag implements Tag {
|
||||
public static final Codec<CompoundTag> CODEC = Codec.PASSTHROUGH.comapFlatMap((dynamic) -> {
|
||||
@@ -365,7 +366,7 @@ public class CompoundTag implements Tag {
|
||||
throw new ReportedException(this.createReport(key, ByteArrayTag.TYPE, var3));
|
||||
}
|
||||
|
||||
- return new byte[0];
|
||||
+ return Constants.EMPTY_byte_arr; // Mirai - micro alloc opts
|
||||
}
|
||||
|
||||
public int[] getIntArray(String key) {
|
||||
@@ -377,7 +378,7 @@ public class CompoundTag implements Tag {
|
||||
throw new ReportedException(this.createReport(key, IntArrayTag.TYPE, var3));
|
||||
}
|
||||
|
||||
- return new int[0];
|
||||
+ return Constants.EMPTY_int_arr; // Mirai - micro alloc opts
|
||||
}
|
||||
|
||||
public long[] getLongArray(String key) {
|
||||
@@ -389,7 +390,7 @@ public class CompoundTag implements Tag {
|
||||
throw new ReportedException(this.createReport(key, LongArrayTag.TYPE, var3));
|
||||
}
|
||||
|
||||
- return new long[0];
|
||||
+ return Constants.EMPTY_long_arr; // Mirai - micro alloc opts
|
||||
}
|
||||
|
||||
public CompoundTag getCompound(String key) {
|
||||
diff --git a/src/main/java/net/minecraft/nbt/IntArrayTag.java b/src/main/java/net/minecraft/nbt/IntArrayTag.java
|
||||
index a14b01cee7a8d7022c4fa7264d349a76be143ba5..1753971b142e7e03791eece5704a9c4262d7f5ab 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/IntArrayTag.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/IntArrayTag.java
|
||||
@@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
public class IntArrayTag extends CollectionTag<IntTag> {
|
||||
|
||||
@@ -184,7 +185,7 @@ public class IntArrayTag extends CollectionTag<IntTag> {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
- this.data = new int[0];
|
||||
+ this.data = Constants.EMPTY_int_arr; // Mirai - micro alloc opts
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
index ea68b26e506e48d8238b7ee4266e61b211d52bd2..91122d2cb3bd9602da39b49569a9442457ee4df5 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
@@ -10,6 +10,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
public class ListTag extends CollectionTag<Tag> {
|
||||
private static final int SELF_SIZE_IN_BITS = 296;
|
||||
@@ -221,7 +222,7 @@ public class ListTag extends CollectionTag<Tag> {
|
||||
}
|
||||
}
|
||||
|
||||
- return new int[0];
|
||||
+ return Constants.EMPTY_int_arr; // Mirai - micro alloc opts
|
||||
}
|
||||
|
||||
public long[] getLongArray(int index) {
|
||||
@@ -232,7 +233,7 @@ public class ListTag extends CollectionTag<Tag> {
|
||||
}
|
||||
}
|
||||
|
||||
- return new long[0];
|
||||
+ return Constants.EMPTY_long_arr; // Mirai - micro alloc opts
|
||||
}
|
||||
|
||||
public double getDouble(int index) {
|
||||
diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java
|
||||
index db22fc485e6091bd81c0c369f302c6ffb4157448..bc5712bb1f5fea850bb7a881c9f59de18d3494f6 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/StoredUserList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/StoredUserList.java
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.Util;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
public abstract class StoredUserList<K, V extends StoredUserEntry<K>> {
|
||||
|
||||
@@ -100,7 +101,7 @@ public abstract class StoredUserList<K, V extends StoredUserEntry<K>> {
|
||||
}
|
||||
|
||||
public String[] getUserList() {
|
||||
- return (String[]) this.map.keySet().toArray(new String[0]);
|
||||
+ return (String[]) this.map.keySet().toArray(Constants.EMPTY_str_arr); // Mirai - micro alloc opts
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
index 5d8e9bdf5538b19681f21949368d862fab8a89ad..fbe7a74fa32c17394bc93ebde64329798bbf1a95 100644
|
||||
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
@@ -3,9 +3,10 @@ package net.minecraft.util;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.IntConsumer;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
public class ZeroBitStorage implements BitStorage {
|
||||
- public static final long[] RAW = new long[0];
|
||||
+ public static final long[] RAW = Constants.EMPTY_long_arr; // Mirai - micro alloc opts
|
||||
private final int size;
|
||||
|
||||
public ZeroBitStorage(int size) {
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java
|
||||
index 9e3f9099cc47e6c6e40d11ef6d6e83fbf19a3cf7..f4f063f86a1ccef6e84eb91d1c1a248e87a9df77 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java
|
||||
@@ -28,6 +28,7 @@ import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
// CraftBukkit end
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
public class ShapedRecipe implements CraftingRecipe {
|
||||
|
||||
@@ -242,7 +243,7 @@ public class ShapedRecipe implements CraftingRecipe {
|
||||
}
|
||||
|
||||
if (pattern.length == l) {
|
||||
- return new String[0];
|
||||
+ return Constants.EMPTY_str_arr; // Mirai - micro alloc opts
|
||||
} else {
|
||||
String[] astring1 = new String[pattern.length - l - k];
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
index fb15ece736dde16066818216749fb2efba0b3b21..8c6bede6260e1b3759b4a4f9b83c71e183bcec93 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
@@ -54,6 +54,7 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.FurnaceStartSmeltEvent;
|
||||
import org.bukkit.inventory.CookingRecipe;
|
||||
// CraftBukkit end
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
|
||||
public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeHolder, StackedContentsCompatible {
|
||||
|
||||
@@ -61,7 +62,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||
protected static final int SLOT_FUEL = 1;
|
||||
protected static final int SLOT_RESULT = 2;
|
||||
public static final int DATA_LIT_TIME = 0;
|
||||
- private static final int[] SLOTS_FOR_UP = new int[]{0};
|
||||
+ private static final int[] SLOTS_FOR_UP = Constants.ZERO_int_arr; // Mirai - micro alloc opts
|
||||
private static final int[] SLOTS_FOR_DOWN = new int[]{2, 1};
|
||||
private static final int[] SLOTS_FOR_SIDES = new int[]{1};
|
||||
public static final int DATA_LIT_DURATION = 1;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
||||
index cc63322d73519840352ae1de8e20eda84b840f6b..4cce52635fef6e9609ad85aae897012f3dc4c2d0 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
||||
@@ -19,6 +19,8 @@ import java.io.InputStream;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
// CraftBukkit end
|
||||
|
||||
+import me.titaniumtown.Constants; // Mirai - micro alloc opts
|
||||
+
|
||||
public class PlayerDataStorage {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -151,7 +153,7 @@ public class PlayerDataStorage {
|
||||
String[] astring = this.playerDir.list();
|
||||
|
||||
if (astring == null) {
|
||||
- astring = new String[0];
|
||||
+ astring = Constants.EMPTY_str_arr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < astring.length; ++i) {
|
||||
Reference in New Issue
Block a user