mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 03:55:14 +01:00
Fix missing profiler.pop() in PathFinder::findPath (#10320)
This commit is contained in:
parent
62b220a87f
commit
ab1afb0ed8
@ -16,7 +16,7 @@ This lets us get faster foreach iteration, as well as avoids map lookups on
|
|||||||
the values when needed.
|
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
|
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 8519383a9abd45434c1e9888e77548941a80c79c..eb18494bd7257fa5eb00dea16cf4d5667b796f2b 100644
|
index 8519383a9abd45434c1e9888e77548941a80c79c..8aa4ac3a6affbe888d6084a27b668c58dfda6c79 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
@@ -38,9 +38,12 @@ public class PathFinder {
|
@@ -38,9 +38,12 @@ public class PathFinder {
|
||||||
@ -91,7 +91,7 @@ index 8519383a9abd45434c1e9888e77548941a80c79c..eb18494bd7257fa5eb00dea16cf4d566
|
|||||||
if (node2.inOpenSet()) {
|
if (node2.inOpenSet()) {
|
||||||
this.openSet.changeCost(node2, node2.g + node2.h);
|
this.openSet.changeCost(node2, node2.g + node2.h);
|
||||||
} else {
|
} else {
|
||||||
@@ -105,23 +113,31 @@ public class PathFinder {
|
@@ -105,23 +113,32 @@ public class PathFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +100,6 @@ index 8519383a9abd45434c1e9888e77548941a80c79c..eb18494bd7257fa5eb00dea16cf4d566
|
|||||||
- }).min(Comparator.comparingInt(Path::getNodeCount)) : set.stream().map((target) -> {
|
- }).min(Comparator.comparingInt(Path::getNodeCount)) : set.stream().map((target) -> {
|
||||||
- return this.reconstructPath(target.getBestNode(), positions.get(target), false);
|
- return this.reconstructPath(target.getBestNode(), positions.get(target), false);
|
||||||
- }).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount));
|
- }).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount));
|
||||||
- profiler.pop();
|
|
||||||
- return optional.isEmpty() ? null : optional.get();
|
|
||||||
+ // Paper start - Perf: remove streams and optimize collection
|
+ // Paper start - Perf: remove streams and optimize collection
|
||||||
+ Path best = null;
|
+ Path best = null;
|
||||||
+ boolean entryListIsEmpty = entryList.isEmpty();
|
+ boolean entryListIsEmpty = entryList.isEmpty();
|
||||||
@ -112,6 +110,8 @@ index 8519383a9abd45434c1e9888e77548941a80c79c..eb18494bd7257fa5eb00dea16cf4d566
|
|||||||
+ if (best == null || comparator.compare(path, best) < 0)
|
+ if (best == null || comparator.compare(path, best) < 0)
|
||||||
+ best = path;
|
+ best = path;
|
||||||
+ }
|
+ }
|
||||||
|
profiler.pop();
|
||||||
|
- return optional.isEmpty() ? null : optional.get();
|
||||||
+ return best;
|
+ return best;
|
||||||
+ // Paper end - Perf: remove streams and optimize collection
|
+ // Paper end - Perf: remove streams and optimize collection
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user