103 Zeilen
4.1 KiB
Diff
103 Zeilen
4.1 KiB
Diff
From d62facce1542c708d4fb2c5f8a81125a8c969943 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index bee715b..5c67fe4 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
@@ -13,8 +13,7 @@ import java.util.Set;
|
|
|
|
public class ChunkRegionLoader implements IAsyncChunkSaver, IChunkLoader {
|
|
|
|
- private List a = new ArrayList();
|
|
- private Set b = new HashSet();
|
|
+ private java.util.LinkedHashMap<ChunkCoordIntPair, PendingChunkToSave> pendingSaves = new java.util.LinkedHashMap<ChunkCoordIntPair, PendingChunkToSave>(); // Spigot
|
|
private Object c = new Object();
|
|
private final File d;
|
|
|
|
@@ -27,13 +26,11 @@ public class ChunkRegionLoader implements IAsyncChunkSaver, IChunkLoader {
|
|
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
|
|
|
|
synchronized (this.c) {
|
|
- if (this.b.contains(chunkcoordintpair)) {
|
|
- for (int k = 0; k < this.a.size(); ++k) {
|
|
- if (((PendingChunkToSave) this.a.get(k)).a.equals(chunkcoordintpair)) {
|
|
- return true;
|
|
- }
|
|
- }
|
|
- }
|
|
+ // Spigot start
|
|
+ if (pendingSaves.containsKey(chunkcoordintpair)) {
|
|
+ return true;
|
|
+ }
|
|
+ // Spigot end
|
|
}
|
|
|
|
return RegionFileCache.a(this.d, i, j).chunkExists(i & 31, j & 31);
|
|
@@ -60,14 +57,12 @@ public class ChunkRegionLoader implements IAsyncChunkSaver, IChunkLoader {
|
|
Object object = this.c;
|
|
|
|
synchronized (this.c) {
|
|
- if (this.b.contains(chunkcoordintpair)) {
|
|
- for (int k = 0; k < this.a.size(); ++k) {
|
|
- if (((PendingChunkToSave) this.a.get(k)).a.equals(chunkcoordintpair)) {
|
|
- nbttagcompound = ((PendingChunkToSave) this.a.get(k)).b;
|
|
- break;
|
|
- }
|
|
- }
|
|
+ // Spigot start
|
|
+ PendingChunkToSave pendingchunktosave = pendingSaves.get(chunkcoordintpair);
|
|
+ if (pendingchunktosave != null) {
|
|
+ nbttagcompound = pendingchunktosave.b;
|
|
}
|
|
+ // Spigot end
|
|
}
|
|
|
|
if (nbttagcompound == null) {
|
|
@@ -148,17 +143,11 @@ public class ChunkRegionLoader implements IAsyncChunkSaver, IChunkLoader {
|
|
Object object = this.c;
|
|
|
|
synchronized (this.c) {
|
|
- if (this.b.contains(chunkcoordintpair)) {
|
|
- for (int i = 0; i < this.a.size(); ++i) {
|
|
- if (((PendingChunkToSave) this.a.get(i)).a.equals(chunkcoordintpair)) {
|
|
- this.a.set(i, new PendingChunkToSave(chunkcoordintpair, nbttagcompound));
|
|
- return;
|
|
- }
|
|
- }
|
|
+ // Spigot start
|
|
+ if (this.pendingSaves.put(chunkcoordintpair, new PendingChunkToSave(chunkcoordintpair, nbttagcompound)) != null) {
|
|
+ return;
|
|
}
|
|
-
|
|
- this.a.add(new PendingChunkToSave(chunkcoordintpair, nbttagcompound));
|
|
- this.b.add(chunkcoordintpair);
|
|
+ // Spigot end
|
|
FileIOThread.a.a(this);
|
|
}
|
|
}
|
|
@@ -168,12 +157,14 @@ public class ChunkRegionLoader implements IAsyncChunkSaver, IChunkLoader {
|
|
Object object = this.c;
|
|
|
|
synchronized (this.c) {
|
|
- if (this.a.isEmpty()) {
|
|
+ // Spigot start
|
|
+ if (this.pendingSaves.isEmpty()) {
|
|
return false;
|
|
}
|
|
|
|
- pendingchunktosave = (PendingChunkToSave) this.a.remove(0);
|
|
- this.b.remove(pendingchunktosave.a);
|
|
+ pendingchunktosave = this.pendingSaves.values().iterator().next();
|
|
+ this.pendingSaves.remove(pendingchunktosave.a);
|
|
+ // Spigot end
|
|
}
|
|
|
|
if (pendingchunktosave != null) {
|
|
--
|
|
1.8.1.2
|
|
|