mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Merge pull request #162 from cybertiger/region-file-io-ops
Reduce IO ops opening a new region file.
This commit is contained in:
commit
a3b6db55c2
1 changed files with 51 additions and 0 deletions
51
0121-Reduce-IO-ops-opening-a-new-region-file.patch
Normal file
51
0121-Reduce-IO-ops-opening-a-new-region-file.patch
Normal file
|
@ -0,0 +1,51 @@
|
|||
From 0000000000000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegionFile.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegionFile.java
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
@@ -0,0 +0,0 @@ public class RegionFile {
|
||||
|
||||
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) {
|
||||
@@ -0,0 +0,0 @@ public class RegionFile {
|
||||
}
|
||||
|
||||
for (j = 0; j < 1024; ++j) {
|
||||
- k = this.c.readInt();
|
||||
+ k = headerAsInts.get(); // Paper
|
||||
this.e[j] = k;
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
--
|
Loading…
Reference in a new issue