2017-03-25 06:22:02 +01:00
|
|
|
From 37db8b5f7d7fc19b87d5bc444491d60d1197aa0c Mon Sep 17 00:00:00 2001
|
2016-03-29 05:57:26 +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
|
2017-03-25 06:22:02 +01:00
|
|
|
index 9cfc46bc2..637e5baaf 100644
|
2016-03-29 05:57:26 +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;
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -67,8 +70,16 @@ public class RegionFile {
|
2016-03-29 05:57:26 +02:00
|
|
|
|
|
|
|
int k;
|
|
|
|
|
|
|
|
+ // 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
|
|
|
|
for (j = 0; j < 1024; ++j) {
|
|
|
|
- k = this.c.readInt();
|
|
|
|
+ k = headerAsInts.get(); // Paper
|
|
|
|
this.d[j] = k;
|
|
|
|
if (k != 0 && (k >> 8) + (k & 255) <= this.f.size()) {
|
|
|
|
for (int l = 0; l < (k & 255); ++l) {
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -78,7 +89,7 @@ public class RegionFile {
|
2016-03-29 05:57:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < 1024; ++j) {
|
|
|
|
- k = this.c.readInt();
|
|
|
|
+ k = headerAsInts.get(); // Paper
|
|
|
|
this.e[j] = k;
|
|
|
|
}
|
|
|
|
} catch (IOException ioexception) {
|
|
|
|
--
|
2017-03-25 06:22:02 +01:00
|
|
|
2.12.0.windows.1
|
2016-03-29 05:57:26 +02:00
|
|
|
|