mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-15 07:01:36 +08:00
Optimize Chunk#getPos
get rid of object creation
This commit is contained in:
parent
adfd86f58a
commit
615cd59fdc
34
Spigot-Server-Patches/0352-Optimize-Chunk-getPos.patch
Normal file
34
Spigot-Server-Patches/0352-Optimize-Chunk-getPos.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From bd27b410c06aa3d5b0d4b93db276d478a3f1ff02 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 28 Aug 2018 21:35:05 -0400
|
||||
Subject: [PATCH] Optimize Chunk#getPos
|
||||
|
||||
Don't create an object just to get chunk coords.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index f3d9211baa..ed6d0dce33 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -169,8 +169,9 @@ public class Chunk implements IChunkAccess {
|
||||
// CraftBukkit start
|
||||
this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||
this.chunkKey = ChunkCoordIntPair.a(this.locX, this.locZ);
|
||||
+ this.chunkCoords = new ChunkCoordIntPair(this.locX, this.locZ); // Paper
|
||||
}
|
||||
-
|
||||
+ private final ChunkCoordIntPair chunkCoords; // Paper
|
||||
public org.bukkit.Chunk bukkitChunk;
|
||||
public boolean mustSave;
|
||||
public boolean newChunk;
|
||||
@@ -1161,7 +1162,7 @@ public class Chunk implements IChunkAccess {
|
||||
}
|
||||
|
||||
public ChunkCoordIntPair getPos() {
|
||||
- return new ChunkCoordIntPair(this.locX, this.locZ);
|
||||
+ return this.chunkCoords; // Paper
|
||||
}
|
||||
|
||||
public boolean b(int i, int j) {
|
||||
--
|
||||
2.18.0
|
||||
|
Loading…
Reference in New Issue
Block a user