Setting the cache is important to access a cache

This commit is contained in:
Aikar 2016-03-22 23:44:35 -04:00
parent fb05841421
commit 97e083b9b0

View File

@ -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