mirror of
https://github.com/Minestom/Minestom.git
synced 2024-08-20 19:33:05 +02:00
Prevent array resizing during server tick
This commit is contained in:
parent
f24ae00c8f
commit
0ab9c79a28
|
@ -112,10 +112,10 @@ public final class MinecraftServer {
|
|||
@Setter
|
||||
private static boolean fixLighting = true;
|
||||
|
||||
// Rate Limiting
|
||||
// Network monitoring
|
||||
private static int rateLimit = 300;
|
||||
private static int maxPacketSize = 30_000;
|
||||
|
||||
// Network
|
||||
private static PacketListenerManager packetListenerManager;
|
||||
private static NettyServer nettyServer;
|
||||
|
||||
|
|
|
@ -120,7 +120,17 @@ public class PerGroupChunkProvider extends ThreadProvider {
|
|||
@NotNull
|
||||
@Override
|
||||
public List<Future<?>> update(long time) {
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
|
||||
List<Future<?>> futures;
|
||||
int potentialSize = 0;
|
||||
|
||||
// Compute the potential array size
|
||||
{
|
||||
for (Map<LongSet, Instance> longSetInstanceMap : instanceInstanceMap.values()) {
|
||||
potentialSize += 1 + longSetInstanceMap.size();
|
||||
}
|
||||
futures = new ArrayList<>(potentialSize);
|
||||
}
|
||||
|
||||
instanceInstanceMap.forEach((instance, instanceMap) -> {
|
||||
|
||||
|
@ -147,6 +157,7 @@ public class PerGroupChunkProvider extends ThreadProvider {
|
|||
chunksIndexes.forEach((long chunkIndex) -> processChunkTick(instance, chunkIndex, time));
|
||||
})));
|
||||
});
|
||||
|
||||
return futures;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user