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

This commit is contained in:
Suppergerrie2 2024-03-15 12:09:47 +01:00
parent ce6e3b23da
commit c136006ed0

View file

@ -100,8 +100,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- }).min(Comparator.comparingInt(Path::getNodeCount)) : set.stream().map((target) -> {
- return this.reconstructPath(target.getBestNode(), positions.get(target), false);
- }).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount));
- profiler.pop();
- return optional.isEmpty() ? null : optional.get();
+ // Paper start - Perf: remove streams and optimize collection
+ Path best = null;
+ boolean entryListIsEmpty = entryList.isEmpty();
@ -112,6 +110,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (best == null || comparator.compare(path, best) < 0)
+ best = path;
+ }
profiler.pop();
- return optional.isEmpty() ? null : optional.get();
+ return best;
+ // Paper end - Perf: remove streams and optimize collection
}