3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-14 18:40:10 +01:00

Fix missing profiler.pop() in PathFinder::findPath (#10320)

Dieser Commit ist enthalten in:
Suppergerrie2 2024-03-15 12:09:47 +01:00 committet von GitHub
Ursprung 62b220a87f
Commit ab1afb0ed8
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -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
} }