aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0140-Faster-redstone-torch-rapid-clock-removal.patch
blob: 046467949ed0fec6a0d46adbb1c841e7f3793335 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From 423558d9e117b9021b2b779379e1234e4529aac6 Mon Sep 17 00:00:00 2001
From: Martin Panzer <postremus1996@googlemail.com>
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 741236289..25a2a5d36 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
@@ -117,9 +117,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();
@@ -202,7 +210,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.12.0.windows.1