Paper/Spigot-Server-Patches/0079-Reduce-IO-ops-opening-a-new-region-file.patch
Zach Brown 70ce6ce831
Move version command update checking to the implementation
This makes it easier for downstream projects (forks) to replace the
version fetching system with their own. It is as simple as implementing
an interface and overriding the default implementation of
org.bukkit.UnsafeValues#getVersionFetcher()

It also makes it easier for us to organize things like the version
history feature.

Lastly I have updated the paper implementation to check against the site
API rather than against jenkins.
2019-05-27 04:13:41 -05:00

53 Zeilen
1.9 KiB
Diff

From 076e36b75d9d6dde7bc0bec57f7c4690b00d4e01 Mon Sep 17 00:00:00 2001
From: Antony Riley <antony@cyberiantiger.org>
Date: Tue, 29 Mar 2016 06:56:23 +0300
Subject: [PATCH] Reduce IO ops opening a new region file.
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index b062a31c4..4e6288e8b 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -26,7 +26,7 @@ public class RegionFile implements AutoCloseable {
private final File file;
// Spigot end
private static final byte[] a = new byte[4096];
- private final RandomAccessFile b;
+ private final RandomAccessFile b; private RandomAccessFile getDataFile() { return this.b; } // Paper - OBFHELPER
private final int[] c = new int[1024];
private final int[] d = new int[1024];
private final List<Boolean> e;
@@ -59,10 +59,19 @@ public class RegionFile implements AutoCloseable {
this.e.set(1, false);
this.b.seek(0L);
+ // Paper Start
+ java.nio.ByteBuffer header = java.nio.ByteBuffer.allocate(8192);
+ while (header.hasRemaining()) {
+ if (this.getDataFile().getChannel().read(header) == -1) throw new java.io.EOFException();
+ }
+ header.clear();
+ java.nio.IntBuffer headerAsInts = header.asIntBuffer();
+ // Paper End
+
int k;
for (j = 0; j < 1024; ++j) {
- k = this.b.readInt();
+ k = headerAsInts.get(); // Paper
this.c[j] = k;
// Spigot start
int length = k & 255;
@@ -88,7 +97,7 @@ public class RegionFile implements AutoCloseable {
}
for (j = 0; j < 1024; ++j) {
- k = this.b.readInt();
+ k = headerAsInts.get(); // Paper
this.d[j] = k;
}
--
2.21.0