mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 08:47:35 +01:00
Setting the cache is important to access a cache
This commit is contained in:
parent
fb05841421
commit
97e083b9b0
@ -4,8 +4,7 @@ Date: Thu, 27 Aug 2015 01:15:02 -0400
|
|||||||
Subject: [PATCH] Optimize Chunk Access
|
Subject: [PATCH] Optimize Chunk Access
|
||||||
|
|
||||||
getting a loaded chunk is one of the most hottest pieces of code in the game.
|
getting a loaded chunk is one of the most hottest pieces of code in the game.
|
||||||
Often, getChunkAt is called for the same chunk multiple times in a row, often
|
getChunkAt is called for the same chunk multiple times in a row, often from getType();
|
||||||
from getType();
|
|
||||||
|
|
||||||
Optimize this look up by using a Last Access cache.
|
Optimize this look up by using a Last Access cache.
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ if (lastChunkByPos != null && key == lastChunkByPos.chunkKey) {
|
+ if (lastChunkByPos != null && key == lastChunkByPos.chunkKey) {
|
||||||
+ return lastChunkByPos;
|
+ return lastChunkByPos;
|
||||||
+ }
|
+ }
|
||||||
+ return super.get(key);
|
+ return lastChunkByPos = super.get(key);
|
||||||
+ }
|
+ }
|
||||||
+ }; // CraftBukkit
|
+ }; // CraftBukkit
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
Loading…
Reference in New Issue
Block a user