aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0086-Reduce-IO-ops-opening-a-new-region-file.patch
blob: 5462530b44512157d87a85809f0ed8ad7ff511e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From 6411f52ac4ce53d7de71028c657dfc2e6b89e001 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 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