mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
46 lines
2 KiB
Diff
46 lines
2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/util/thread/StrictQueue.java
|
|
+++ b/src/main/java/net/minecraft/util/thread/StrictQueue.java
|
|
@@ -0,0 +0,0 @@ public interface StrictQueue<T, F> {
|
|
private final List<Queue<Runnable>> queueList;
|
|
|
|
public FixedPriorityQueue(int priorityCount) {
|
|
- this.queueList = IntStream.range(0, priorityCount).mapToObj((i) -> {
|
|
- 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.queueList.add(Queues.newConcurrentLinkedQueue());
|
|
+ }
|
|
+ // Paper end - remove streams
|
|
}
|
|
|
|
@Nullable
|
|
@@ -0,0 +0,0 @@ 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.queueList.size(); i < len; ++i) {
|
|
+ Queue<Runnable> queue = this.queueList.get(i);
|
|
+ if (!queue.isEmpty()) {
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+ return true;
|
|
+ // Paper end - remove streams
|
|
}
|
|
|
|
@Override
|