2019-01-01 04:15:55 +01:00
|
|
|
From df54abcfdf2bbf943dbd4a193e9edcc7af8f7cdf Mon Sep 17 00:00:00 2001
|
2018-07-15 03:53:17 +02:00
|
|
|
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
|
2019-01-01 04:15:55 +01:00
|
|
|
index 9299ab56a..407ac75aa 100644
|
2018-07-15 03:53:17 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/RegionFile.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/RegionFile.java
|
|
|
|
@@ -8,9 +8,12 @@ import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.DataInputStream;
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
+import java.io.EOFException;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.RandomAccessFile;
|
|
|
|
+import java.nio.ByteBuffer;
|
|
|
|
+import java.nio.IntBuffer;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.zip.DeflaterOutputStream;
|
|
|
|
import java.util.zip.GZIPInputStream;
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -65,11 +68,18 @@ public class RegionFile {
|
2018-09-01 00:56:57 +02:00
|
|
|
this.f.set(1, false);
|
|
|
|
this.c.seek(0L);
|
2018-07-15 03:53:17 +02:00
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
- int k;
|
2018-07-15 03:53:17 +02:00
|
|
|
+ // Paper Start
|
|
|
|
+ ByteBuffer header = ByteBuffer.allocate(8192);
|
|
|
|
+ while (header.hasRemaining()) {
|
|
|
|
+ if (this.c.getChannel().read(header) == -1) throw new EOFException();
|
|
|
|
+ }
|
|
|
|
+ header.clear();
|
|
|
|
+ IntBuffer headerAsInts = header.asIntBuffer();
|
|
|
|
+ // Paper End
|
2019-01-01 04:15:55 +01:00
|
|
|
|
|
|
|
- for (j = 0; j < 1024; ++j) {
|
|
|
|
- k = this.c.readInt();
|
|
|
|
- this.d[j] = k;
|
|
|
|
+ for(int j1 = 0; j1 < 1024; ++j1) {
|
2018-09-01 00:56:57 +02:00
|
|
|
+ int k = headerAsInts.get(); // Paper
|
2019-01-01 04:15:55 +01:00
|
|
|
+ this.d[j1] = k;
|
2018-07-15 03:53:17 +02:00
|
|
|
if (k != 0 && (k >> 8) + (k & 255) <= this.f.size()) {
|
2019-01-01 04:15:55 +01:00
|
|
|
for (int l = 0; l < (k & 255); ++l) {
|
|
|
|
this.f.set((k >> 8) + l, false);
|
|
|
|
@@ -78,7 +88,7 @@ public class RegionFile {
|
2018-07-15 03:53:17 +02:00
|
|
|
}
|
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
for (j = 0; j < 1024; ++j) {
|
|
|
|
- k = this.c.readInt();
|
|
|
|
+ int k = headerAsInts.get(); // Paper
|
|
|
|
this.e[j] = k;
|
2018-07-15 03:53:17 +02:00
|
|
|
}
|
|
|
|
} catch (IOException ioexception) {
|
|
|
|
--
|
2019-01-01 04:15:55 +01:00
|
|
|
2.20.1
|
2018-07-15 03:53:17 +02:00
|
|
|
|