From 6411f52ac4ce53d7de71028c657dfc2e6b89e001 Mon Sep 17 00:00:00 2001 From: Antony Riley 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 9626396745..e2d4450e90 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -71,9 +71,17 @@ public class RegionFile { this.c.seek(0L); int k; + // Paper Start + java.nio.ByteBuffer header = java.nio.ByteBuffer.allocate(8192); + while (header.hasRemaining()) { + if (this.c.getChannel().read(header) == -1) throw new java.io.EOFException(); + } + header.clear(); + java.nio.IntBuffer headerAsInts = header.asIntBuffer(); + // Paper End for (j = 0; j < 1024; ++j) { - k = this.c.readInt(); + k = headerAsInts.get(); // Paper this.d[j] = k; // Spigot start int length = k & 255; @@ -99,7 +107,7 @@ public class RegionFile { } for (j = 0; j < 1024; ++j) { - k = this.c.readInt(); + k = headerAsInts.get(); // Paper this.e[j] = k; } } catch (IOException ioexception) { -- 2.20.1