diff options
Diffstat (limited to 'patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch')
-rw-r--r-- | patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch index 76d173106a..8ed7b79355 100644 --- a/patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch +++ b/patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch @@ -16,7 +16,7 @@ This lets us get faster foreach iteration, as well as avoids map lookups on the values when needed. diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -index a2e7040df11a0138c706a10b190111b6c3bd99a9..d1e1f12451058f7f276f8277536a4c0a4d736601 100644 +index 3e27c9a74c38f11a436df8cd413f9f5f16fd8c3e..c4d6b145d54aaf415dd4b08811c024255092e1b8 100644 --- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java @@ -38,8 +38,12 @@ public class PathFinder { @@ -24,7 +24,7 @@ index a2e7040df11a0138c706a10b190111b6c3bd99a9..d1e1f12451058f7f276f8277536a4c0a return null; } else { - Map<Target, BlockPos> map = positions.stream() -- .collect(Collectors.toMap(pos -> this.nodeEvaluator.getGoal((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()), Function.identity())); +- .collect(Collectors.toMap(pos -> this.nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), Function.identity())); + // Paper start - Perf: remove streams and optimize collection + List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList(); + for (BlockPos pos : positions) { @@ -56,7 +56,7 @@ index a2e7040df11a0138c706a10b190111b6c3bd99a9..d1e1f12451058f7f276f8277536a4c0a int i = 0; - Set<Target> set3 = Sets.newHashSetWithExpectedSize(set.size()); + List<Map.Entry<Target, BlockPos>> entryList = Lists.newArrayListWithExpectedSize(positions.size()); // Paper - optimize collection - int j = (int)((float)this.maxVisitedNodes * rangeMultiplier); + int j = (int)(this.maxVisitedNodes * rangeMultiplier); while (!this.openSet.isEmpty()) { @@ -69,14 +74,18 @@ public class PathFinder { @@ -68,7 +68,7 @@ index a2e7040df11a0138c706a10b190111b6c3bd99a9..d1e1f12451058f7f276f8277536a4c0a + for (int i1 = 0; i1 < positions.size(); i1++) { + final Map.Entry<Target, BlockPos> entry = positions.get(i1); + Target target = entry.getKey(); - if (node.distanceManhattan(target) <= (float)distance) { + if (node.distanceManhattan(target) <= distance) { target.setReached(); - set3.add(target); + entryList.add(entry); |