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/0121-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch
2025-06-11 03:59:45 +08:00

25 lines
1.3 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/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
index 0fd51020ca9480be2855eb58a7d4d43511829512..b1400a1cc41717437ccb0f2b7854e54c5b985985 100644
--- a/net/minecraft/server/level/ServerChunkCache.java
+++ b/net/minecraft/server/level/ServerChunkCache.java
@@ -585,7 +585,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
final ServerChunkCache.ChunkAndHolder[] raw = tickingChunks.getRawDataUnchecked();
final int size = tickingChunks.size();
- final ChunkMap chunkMap = this.chunkMap;
+ // 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 ServerChunkCache.ChunkAndHolder chunkAndHolder = raw[i];