More 1.14 updates (#1995)
This commit is contained in:
@@ -11,7 +11,7 @@ The implementation uses a LinkedHashMap as an LRU cache (modified from HashMap).
|
||||
The maximum size of the RegionFileCache is also made configurable.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index e4ba7146d1..06c53af2c5 100644
|
||||
index 809b3a1a4..e929ba452 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperConfig {
|
||||
@@ -25,53 +25,24 @@ index e4ba7146d1..06c53af2c5 100644
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
index 5dbd1d517a..964996976a 100644
|
||||
index 75731c919..c8573a8ee 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
@@ -0,0 +0,0 @@ import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@@ -0,0 +0,0 @@ import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
+import com.destroystokyo.paper.PaperConfig; // Paper
|
||||
+import java.util.LinkedHashMap; // Paper
|
||||
|
||||
public class RegionFileCache {
|
||||
public abstract class RegionFileCache implements AutoCloseable {
|
||||
|
||||
- public static final Map<File, RegionFile> cache = Maps.newHashMap();
|
||||
+ public static final Map<File, RegionFile> cache = new LinkedHashMap(PaperConfig.regionFileCacheSize, 0.75f, true); // Paper - HashMap -> LinkedHashMap
|
||||
|
||||
public static synchronized RegionFile a(File file, int i, int j) {
|
||||
File file1 = new File(file, "region");
|
||||
@@ -0,0 +0,0 @@ public class RegionFileCache {
|
||||
@@ -0,0 +0,0 @@ public abstract class RegionFileCache implements AutoCloseable {
|
||||
if (regionfile != null) {
|
||||
return regionfile;
|
||||
} else {
|
||||
- if (this.cache.size() >= 256) {
|
||||
+ if (this.cache.size() >= PaperConfig.regionFileCacheSize) {
|
||||
this.cache.removeLast();
|
||||
}
|
||||
|
||||
if (RegionFileCache.cache.size() >= 256) {
|
||||
- a();
|
||||
+ trimCache();
|
||||
}
|
||||
|
||||
RegionFile regionfile1 = new RegionFile(file2);
|
||||
@@ -0,0 +0,0 @@ public class RegionFileCache {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
+ // Paper Start
|
||||
+ private static synchronized void trimCache() {
|
||||
+ Iterator<Map.Entry<File, RegionFile>> itr = RegionFileCache.cache.entrySet().iterator();
|
||||
+ int count = RegionFileCache.cache.size() - PaperConfig.regionFileCacheSize;
|
||||
+ while (count-- >= 0 && itr.hasNext()) {
|
||||
+ try {
|
||||
+ itr.next().getValue().close();
|
||||
+ } catch (IOException ioexception) {
|
||||
+ ioexception.printStackTrace();
|
||||
+ ServerInternalException.reportInternalException(ioexception);
|
||||
+ }
|
||||
+ itr.remove();
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper End
|
||||
+
|
||||
public static synchronized void a() {
|
||||
Iterator iterator = RegionFileCache.cache.values().iterator();
|
||||
|
||||
--
|
||||
Reference in New Issue
Block a user