9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0211-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch
2025-06-11 05:20:38 +08:00

24 lines
1.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Sun, 16 Feb 2025 01:13:04 +0100
Subject: [PATCH] Use ensureCapacity to pre-populate the size of ticking chunks
list output
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index 083b49c8fbdbde96b5be3e5531c21b2c96371b60..d77197ff56bd7acd7747af7d0dc937c31fa86a17 100644
--- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java
@@ -733,6 +733,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final int size = tickingChunks.size();
Objects.checkFromToIndex(0, size, raw.length);
+ // Leaf start - Use ensureCapacity to pre-populate the size of ticking chunks list output
+ if (output instanceof ArrayList<LevelChunk> arrayList) {
+ arrayList.ensureCapacity(size);
+ }
+ // Leaf end - Use ensureCapacity to pre-populate the size of ticking chunks list output
for (int i = 0; i < size; ++i) {
final LevelChunk levelChunk = raw[i];