testserver/CraftBukkit-Patches/0007-More-Efficient-Chunk-S...

101 lines
4.1 KiB
Diff
Raw Normal View History

2014-04-12 04:18:37 +00:00
From 4b8464a3c11cd4f4180df88a50d805e6aad0b7b9 Mon Sep 17 00:00:00 2001
2013-06-11 02:10:31 +00:00
From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 12:09:45 +1000
Subject: [PATCH] More Efficient Chunk Save Queue
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2014-04-12 04:18:37 +00:00
index 26bafe0..49acc9a 100644
2013-06-11 02:10:31 +00:00
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2014-04-12 04:18:37 +00:00
@@ -15,6 +15,7 @@ import org.apache.logging.log4j.Logger;
2013-06-11 02:10:31 +00:00
2013-12-01 03:40:53 +00:00
public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2013-06-11 02:10:31 +00:00
2013-06-11 02:13:28 +00:00
+ private java.util.LinkedHashMap<ChunkCoordIntPair, PendingChunkToSave> pendingSaves = new java.util.LinkedHashMap<ChunkCoordIntPair, PendingChunkToSave>(); // Spigot
2013-12-01 03:40:53 +00:00
private static final Logger a = LogManager.getLogger();
private List b = new ArrayList();
private Set c = new HashSet();
2014-04-12 04:18:37 +00:00
@@ -30,13 +31,11 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2013-06-11 02:10:31 +00:00
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
2013-12-01 03:40:53 +00:00
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)) {
2013-06-11 02:10:31 +00:00
- return true;
- }
- }
- }
+ // Spigot start
+ if (pendingSaves.containsKey(chunkcoordintpair)) {
+ return true;
+ }
+ // Spigot end
}
2013-12-01 03:40:53 +00:00
return RegionFileCache.a(this.e, i, j).chunkExists(i & 31, j & 31);
2014-04-12 04:18:37 +00:00
@@ -63,14 +62,12 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2013-12-01 03:40:53 +00:00
Object object = this.d;
2013-06-11 02:10:31 +00:00
2013-12-01 03:40:53 +00:00
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;
2013-06-11 02:10:31 +00:00
- break;
- }
- }
+ // Spigot start
+ PendingChunkToSave pendingchunktosave = pendingSaves.get(chunkcoordintpair);
+ if (pendingchunktosave != null) {
+ nbttagcompound = pendingchunktosave.b;
}
+ // Spigot end
}
if (nbttagcompound == null) {
2014-04-12 04:18:37 +00:00
@@ -150,17 +147,11 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2013-12-01 03:40:53 +00:00
Object object = this.d;
2013-06-11 02:10:31 +00:00
2013-12-01 03:40:53 +00:00
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));
2013-06-11 02:10:31 +00:00
- return;
- }
- }
+ // Spigot start
+ if (this.pendingSaves.put(chunkcoordintpair, new PendingChunkToSave(chunkcoordintpair, nbttagcompound)) != null) {
+ return;
}
-
2013-12-01 03:40:53 +00:00
- this.b.add(new PendingChunkToSave(chunkcoordintpair, nbttagcompound));
- this.c.add(chunkcoordintpair);
2013-06-11 02:10:31 +00:00
+ // Spigot end
FileIOThread.a.a(this);
}
}
2014-04-12 04:18:37 +00:00
@@ -170,12 +161,14 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2013-12-01 03:40:53 +00:00
Object object = this.d;
2013-06-11 02:10:31 +00:00
2013-12-01 03:40:53 +00:00
synchronized (this.d) {
- if (this.b.isEmpty()) {
2013-06-11 02:10:31 +00:00
+ // Spigot start
+ if (this.pendingSaves.isEmpty()) {
return false;
}
2013-12-01 03:40:53 +00:00
- pendingchunktosave = (PendingChunkToSave) this.b.remove(0);
- this.c.remove(pendingchunktosave.a);
2013-06-11 02:10:31 +00:00
+ pendingchunktosave = this.pendingSaves.values().iterator().next();
+ this.pendingSaves.remove(pendingchunktosave.a);
+ // Spigot end
}
if (pendingchunktosave != null) {
--
2013-12-01 03:40:53 +00:00
1.8.3.2
2013-06-11 02:10:31 +00:00