aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Panzer <[email protected]>2016-05-24 20:08:40 -0500
committerZach Brown <[email protected]>2016-05-24 20:08:40 -0500
commit391d0c04f819bfc400af161615743a6b112f817a (patch)
treea51f9f184ef94fe0861d4c58427f11aa74919b9f
parentb71c0e6f49a538f430729eeb8c499886984d06ad (diff)
downloadPaper-391d0c04f819bfc400af161615743a6b112f817a.tar.gz
Paper-391d0c04f819bfc400af161615743a6b112f817a.zip
Optimize Redstone torch list removal
-rw-r--r--Spigot-Server-Patches/0160-Faster-redstone-torch-rapid-clock-removal.patch43
1 files changed, 43 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0160-Faster-redstone-torch-rapid-clock-removal.patch b/Spigot-Server-Patches/0160-Faster-redstone-torch-rapid-clock-removal.patch
new file mode 100644
index 0000000000..cd9c4842f6
--- /dev/null
+++ b/Spigot-Server-Patches/0160-Faster-redstone-torch-rapid-clock-removal.patch
@@ -0,0 +1,43 @@
+From 10a2bb42c44b07bf3854f948f887a3e9ee795720 Mon Sep 17 00:00:00 2001
+From: Martin Panzer <[email protected]>
+Date: Mon, 23 May 2016 12:12:37 +0200
+Subject: [PATCH] Faster redstone torch rapid clock removal
+
+Only resize the the redstone torch list once, since resizing arrays / lists is costly
+
+diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
+index e2f4f44..cf24c45 100644
+--- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
++++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
+@@ -118,9 +118,17 @@ public class BlockRedstoneTorch extends BlockTorch {
+ boolean flag = this.g(world, blockposition, iblockdata);
+ List list = (List) BlockRedstoneTorch.g.get(world);
+
+- while (list != null && !list.isEmpty() && world.getTime() - ((BlockRedstoneTorch.RedstoneUpdateInfo) list.get(0)).b > 60L) {
+- list.remove(0);
++ // Paper start
++ if (list != null) {
++ int index = 0;
++ while (index < list.size() && world.getTime() - ((BlockRedstoneTorch.RedstoneUpdateInfo) list.get(index)).getTime() > 60L) {
++ index++;
++ }
++ if (index > 0) {
++ list.subList(0, index).clear();
++ }
+ }
++ // Paper end
+
+ // CraftBukkit start
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+@@ -204,7 +212,7 @@ public class BlockRedstoneTorch extends BlockTorch {
+ static class RedstoneUpdateInfo {
+
+ BlockPosition a;
+- long b;
++ long b; final long getTime() { return this.b; } // Paper - OBFHELPER
+
+ public RedstoneUpdateInfo(BlockPosition blockposition, long i) {
+ this.a = blockposition;
+--
+2.8.2
+