diff options
Diffstat (limited to 'patches/server/0285-Optimize-Captured-BlockEntity-Lookup.patch')
-rw-r--r-- | patches/server/0285-Optimize-Captured-BlockEntity-Lookup.patch | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/patches/server/0285-Optimize-Captured-BlockEntity-Lookup.patch b/patches/server/0285-Optimize-Captured-BlockEntity-Lookup.patch new file mode 100644 index 0000000000..0cbe385bec --- /dev/null +++ b/patches/server/0285-Optimize-Captured-BlockEntity-Lookup.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +Date: Sat, 6 Apr 2019 10:16:48 -0400 +Subject: [PATCH] Optimize Captured BlockEntity Lookup + +upstream was doing a containsKey/get pattern, and always doing it at that. +that scenario is only even valid if were in the middle of a block place. + +Optimize to check if the captured list even has values in it, and also to +just do a get call since the value can never be null. + +diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java +index 4c4449f7dee8695a362f83b9356e5754244fff18..60b04a16c6cb0a7109bda5c16e23c1d56ab7afad 100644 +--- a/src/main/java/net/minecraft/world/level/Level.java ++++ b/src/main/java/net/minecraft/world/level/Level.java +@@ -912,9 +912,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + + @Nullable + public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { +- if (this.capturedTileEntities.containsKey(blockposition)) { +- return this.capturedTileEntities.get(blockposition); ++ // Paper start - Perf: Optimize capturedTileEntities lookup ++ net.minecraft.world.level.block.entity.BlockEntity blockEntity; ++ if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(blockposition)) != null) { ++ return blockEntity; + } ++ // Paper end - Perf: Optimize capturedTileEntities lookup + // CraftBukkit end + return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); + } |