diff options
Diffstat (limited to 'patches/server-remapped/0441-Remove-streams-from-PairedQueue.patch')
-rw-r--r-- | patches/server-remapped/0441-Remove-streams-from-PairedQueue.patch | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/patches/server-remapped/0441-Remove-streams-from-PairedQueue.patch b/patches/server-remapped/0441-Remove-streams-from-PairedQueue.patch deleted file mode 100644 index 935abedc0d..0000000000 --- a/patches/server-remapped/0441-Remove-streams-from-PairedQueue.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf <[email protected]> -Date: Mon, 6 Apr 2020 18:10:43 -0700 -Subject: [PATCH] Remove streams from PairedQueue - -We shouldn't be doing stream calls just to see if the queue is -empty. This creates loads of garbage thanks to how often it's called. - -diff --git a/src/main/java/net/minecraft/util/thread/StrictQueue.java b/src/main/java/net/minecraft/util/thread/StrictQueue.java -index cdc572b0261034248960fa13b8412e874fd20db5..07938519b699a31a280f3f419b34fb7cf6cf6883 100644 ---- a/src/main/java/net/minecraft/util/thread/StrictQueue.java -+++ b/src/main/java/net/minecraft/util/thread/StrictQueue.java -@@ -20,32 +20,30 @@ public interface StrictQueue<T, F> { - - public static final class FixedPriorityQueue implements StrictQueue<StrictQueue.IntRunnable, Runnable> { - -- private final List<Queue<Runnable>> queueList; -+ private final List<Queue<Runnable>> queueList; private final List<Queue<Runnable>> getQueues() { return this.queueList; } // Paper - OBFHELPER - - public FixedPriorityQueue(int priorityCount) { -- this.queueList = (List) IntStream.range(0, priorityCount).mapToObj((j) -> { -- return Queues.newConcurrentLinkedQueue(); -- }).collect(Collectors.toList()); -+ // Paper start - remove streams -+ this.queueList = new java.util.ArrayList<>(priorityCount); // queues -+ for (int j = 0; j < priorityCount; ++j) { -+ this.getQueues().add(Queues.newConcurrentLinkedQueue()); -+ } -+ // Paper end - remove streams - } - - @Nullable - @Override - public Runnable pop() { -- Iterator iterator = this.queueList.iterator(); -- -- Runnable runnable; -- -- do { -- if (!iterator.hasNext()) { -- return null; -+ // Paper start - remove iterator creation -+ for (int i = 0, len = this.getQueues().size(); i < len; ++i) { -+ Queue<Runnable> queue = this.getQueues().get(i); -+ Runnable ret = queue.poll(); -+ if (ret != null) { -+ return ret; - } -- -- Queue<Runnable> queue = (Queue) iterator.next(); -- -- runnable = (Runnable) queue.poll(); -- } while (runnable == null); -- -- return runnable; -+ } -+ return null; -+ // Paper end - remove iterator creation - } - - public boolean push(StrictQueue.IntRunnable message) { -@@ -57,7 +55,16 @@ public interface StrictQueue<T, F> { - - @Override - public boolean isEmpty() { -- return this.queueList.stream().allMatch(Collection::isEmpty); -+ // Paper start - remove streams -+ // why are we doing streams every time we might want to execute a task? -+ for (int i = 0, len = this.getQueues().size(); i < len; ++i) { -+ Queue<Runnable> queue = this.getQueues().get(i); -+ if (!queue.isEmpty()) { -+ return false; -+ } -+ } -+ return true; -+ // Paper end - remove streams - } - } - |