aboutsummaryrefslogtreecommitdiffhomepage
path: root/CraftBukkit-Patches/0008-More-Efficient-Chunk-Save-Queue.patch
diff options
context:
space:
mode:
Diffstat (limited to 'CraftBukkit-Patches/0008-More-Efficient-Chunk-Save-Queue.patch')
-rw-r--r--CraftBukkit-Patches/0008-More-Efficient-Chunk-Save-Queue.patch101
1 files changed, 101 insertions, 0 deletions
diff --git a/CraftBukkit-Patches/0008-More-Efficient-Chunk-Save-Queue.patch b/CraftBukkit-Patches/0008-More-Efficient-Chunk-Save-Queue.patch
new file mode 100644
index 0000000000..6faddb86f7
--- /dev/null
+++ b/CraftBukkit-Patches/0008-More-Efficient-Chunk-Save-Queue.patch
@@ -0,0 +1,101 @@
+From ab91f465135140c44a48dc5e8dee0f3d8d0feaf4 Mon Sep 17 00:00:00 2001
+From: md_5 <[email protected]>
+Date: Tue, 11 Jun 2013 12:09:45 +1000
+Subject: [PATCH] More Efficient Chunk Save Queue
+
+Optimizes the data structures behind the chunk save queue into ones more suitable for the type of data and access which they are used for.
+
+diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+index 9402f0f..ea45af2 100644
+--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
++++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+@@ -15,6 +15,7 @@ import org.apache.logging.log4j.Logger;
+
+ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+
++ private java.util.LinkedHashMap<ChunkCoordIntPair, PendingChunkToSave> pendingSaves = new java.util.LinkedHashMap<ChunkCoordIntPair, PendingChunkToSave>(); // Spigot
+ private static final Logger a = LogManager.getLogger();
+ private List b = new ArrayList();
+ private Set c = new HashSet();
+@@ -30,13 +31,11 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+ ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
+
+ synchronized (this.d) {
+- if (this.c.contains(chunkcoordintpair)) {
+- for (int k = 0; k < this.b.size(); ++k) {
+- if (((PendingChunkToSave) this.b.get(k)).a.equals(chunkcoordintpair)) {
+- return true;
+- }
+- }
+- }
++ // Spigot start
++ if (pendingSaves.containsKey(chunkcoordintpair)) {
++ return true;
++ }
++ // Spigot end
+ }
+
+ return RegionFileCache.a(this.e, i, j).chunkExists(i & 31, j & 31);
+@@ -63,14 +62,12 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+ Object object = this.d;
+
+ synchronized (this.d) {
+- if (this.c.contains(chunkcoordintpair)) {
+- for (int k = 0; k < this.b.size(); ++k) {
+- if (((PendingChunkToSave) this.b.get(k)).a.equals(chunkcoordintpair)) {
+- nbttagcompound = ((PendingChunkToSave) this.b.get(k)).b;
+- break;
+- }
+- }
++ // Spigot start
++ PendingChunkToSave pendingchunktosave = pendingSaves.get(chunkcoordintpair);
++ if (pendingchunktosave != null) {
++ nbttagcompound = pendingchunktosave.b;
+ }
++ // Spigot end
+ }
+
+ if (nbttagcompound == null) {
+@@ -150,17 +147,11 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+ Object object = this.d;
+
+ synchronized (this.d) {
+- if (this.c.contains(chunkcoordintpair)) {
+- for (int i = 0; i < this.b.size(); ++i) {
+- if (((PendingChunkToSave) this.b.get(i)).a.equals(chunkcoordintpair)) {
+- this.b.set(i, new PendingChunkToSave(chunkcoordintpair, nbttagcompound));
+- return;
+- }
+- }
++ // Spigot start
++ if (this.pendingSaves.put(chunkcoordintpair, new PendingChunkToSave(chunkcoordintpair, nbttagcompound)) != null) {
++ return;
+ }
+-
+- this.b.add(new PendingChunkToSave(chunkcoordintpair, nbttagcompound));
+- this.c.add(chunkcoordintpair);
++ // Spigot end
+ FileIOThread.a.a(this);
+ }
+ }
+@@ -170,12 +161,14 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+ Object object = this.d;
+
+ synchronized (this.d) {
+- if (this.b.isEmpty()) {
++ // Spigot start
++ if (this.pendingSaves.isEmpty()) {
+ return false;
+ }
+
+- pendingchunktosave = (PendingChunkToSave) this.b.remove(0);
+- this.c.remove(pendingchunktosave.a);
++ pendingchunktosave = this.pendingSaves.values().iterator().next();
++ this.pendingSaves.remove(pendingchunktosave.a);
++ // Spigot end
+ }
+
+ if (pendingchunktosave != null) {
+--
+1.9.1
+