mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
6d1a918378
This work is 100% unfinished. I am pushing it up so that we as a team can work on this update. Do not try to use this branch. You will fail.
38 lines
No EOL
1.3 KiB
Diff
38 lines
No EOL
1.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 27 Aug 2015 01:15:02 -0400
|
|
Subject: [PATCH] Optimize Chunk Access
|
|
|
|
getting a loaded chunk is one of the most hottest pieces of code in the game.
|
|
getChunkAt is called for the same chunk multiple times in a row, often from getType();
|
|
|
|
Optimize this look up by using a Last Access cache.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkMap.java b/src/main/java/net/minecraft/server/ChunkMap.java
|
|
index 0c2386f5e..5757aa80f 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkMap.java
|
|
@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
|
}
|
|
}
|
|
|
|
+ // Paper start
|
|
+ if (lastChunkByPos != null && i == lastChunkByPos.chunkKey) {
|
|
+ lastChunkByPos = null;
|
|
+ }
|
|
return chunk;
|
|
}
|
|
+ private Chunk lastChunkByPos = null; // Paper
|
|
+
|
|
+ @Override
|
|
+ public Chunk get(long l) {
|
|
+ if (lastChunkByPos != null && l == lastChunkByPos.chunkKey) {
|
|
+ return lastChunkByPos;
|
|
+ }
|
|
+ return super.get(l);
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public Chunk a(Object object) {
|
|
return this.a(((Long) object).longValue());
|
|
--
|