mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
4104545b11
"It was from a different time before books were as jank as they are now. As time has gone on they've only proven to be worse and worse."
47 lines
2.0 KiB
Diff
47 lines
2.0 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 66591e23bc9e0df968fb6b291a3ad3773debdf29..c4a20df21e1fe5556fddac64b52d542579758e2c 100644
|
|
--- a/src/main/java/net/minecraft/util/thread/StrictQueue.java
|
|
+++ b/src/main/java/net/minecraft/util/thread/StrictQueue.java
|
|
@@ -22,9 +22,12 @@ 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
|
|
@@ -49,7 +52,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.queueList.size(); i < len; ++i) {
|
|
+ Queue<Runnable> queue = this.queueList.get(i);
|
|
+ if (!queue.isEmpty()) {
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+ return true;
|
|
+ // Paper end - remove streams
|
|
}
|
|
|
|
@Override
|