Paper/CraftBukkit-Patches/0013-Sync-Free-Chunk-Reference-Cache.patch

43 lines
1.7 KiB
Diff
Raw Normal View History

2013-12-22 00:05:27 +01:00
From 78a32c982fa003401ef5b2bd3c0746786d6dec3b Mon Sep 17 00:00:00 2001
From: Mike Primm <mike@primmhome.com>
Date: Wed, 16 Jan 2013 15:27:22 -0600
Subject: [PATCH] Sync Free Chunk Reference Cache
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2013-12-22 00:05:27 +01:00
index 1381660..00c2a18 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2013-12-09 08:00:58 +01:00
@@ -292,20 +292,18 @@ public abstract class World implements IBlockAccess {
2013-12-01 04:40:53 +01:00
return this.getChunkAt(i >> 4, j >> 4);
}
2013-12-01 04:40:53 +01:00
+ // Spigot start
public Chunk getChunkAt(int i, int j) {
2013-12-01 04:40:53 +01:00
- // CraftBukkit start
- 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
2013-12-01 05:36:32 +01:00
+ if (result == null || result.locX != i || result.locZ != j) {
+ result = this.chunkProvider.getOrCreateChunk(i, j);
+ this.lastChunkAccessed = result; // Exploit fact that write is atomic
}
+ //}
return result;
2013-12-01 04:40:53 +01:00
- // CraftBukkit end
}
2013-12-01 04:40:53 +01:00
+ // Spigot end
public boolean setTypeAndData(int i, int j, int k, Block block, int l, int i1) {
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
--
2013-12-01 04:40:53 +01:00
1.8.3.2