2013-04-10 04:06:41 +00:00
|
|
|
From 2338cb87b1abac89c21f2f9bbcfe19177e92e90c Mon Sep 17 00:00:00 2001
|
2013-01-19 08:22:07 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
---
|
2013-04-10 02:36:11 +00:00
|
|
|
src/main/java/net/minecraft/server/World.java | 14 ++++++--------
|
|
|
|
1 file changed, 6 insertions(+), 8 deletions(-)
|
2013-01-19 08:22:07 +00:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2013-04-10 02:36:11 +00:00
|
|
|
index 92e8a37..b4ec71e 100644
|
2013-01-19 08:22:07 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2013-03-15 21:35:56 +00:00
|
|
|
@@ -294,15 +294,13 @@ public abstract class World implements IBlockAccess {
|
2013-01-19 08:22:07 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
--
|
2013-04-10 02:36:11 +00:00
|
|
|
1.8.2.1
|
2013-01-19 08:22:07 +00:00
|
|
|
|