mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 06:20:13 +01:00
Sync free, but still safe reference cache for chunk loading.
This commit is contained in:
parent
cfd861ca46
commit
22bb4da32a
1 changed files with 38 additions and 0 deletions
|
@ -0,0 +1,38 @@
|
|||
From 369fd92f61f955ef427c3db66a650458b095f26a Mon Sep 17 00:00:00 2001
|
||||
From: Mike Primm <mike@primmhome.com>
|
||||
Date: Wed, 16 Jan 2013 15:27:22 -0600
|
||||
Subject: [PATCH] Alternate, sync-free-but-safe chunk reference cache
|
||||
|
||||
---
|
||||
src/main/java/net/minecraft/server/World.java | 14 ++++++--------
|
||||
1 file changed, 6 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 6e9b13d..e28aa00 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -297,15 +297,13 @@ public abstract class World implements IBlockAccess {
|
||||
|
||||
// CraftBukkit start
|
||||
public Chunk getChunkAt(int i, int j) {
|
||||
- Chunk result = null;
|
||||
- synchronized (this.chunkLock) {
|
||||
- if (this.lastChunkAccessed == null || this.lastXAccessed != i || this.lastZAccessed != j) {
|
||||
- this.lastChunkAccessed = this.chunkProvider.getOrCreateChunk(i, j);
|
||||
- this.lastXAccessed = i;
|
||||
- this.lastZAccessed = j;
|
||||
- }
|
||||
- result = this.lastChunkAccessed;
|
||||
+ //synchronized (this.chunkLock) {
|
||||
+ Chunk result = this.lastChunkAccessed; // Exploit fact that read is atomic
|
||||
+ if (result == null || result.x != i || result.z != j) {
|
||||
+ result = this.chunkProvider.getOrCreateChunk(i, j);
|
||||
+ this.lastChunkAccessed = result; // Exploit fact that write is atomic
|
||||
}
|
||||
+ //}
|
||||
return result;
|
||||
}
|
||||
// CraftBukkit end
|
||||
--
|
||||
1.8.1-rc2
|
||||
|
Loading…
Reference in a new issue