From f0b6208d951f0a3c7ee3da64f69fed2812411720 Mon Sep 17 00:00:00 2001 From: Ryley Kimmel Date: Wed, 25 Feb 2015 23:51:14 -0500 Subject: [PATCH] Remove the redundant createIfAbsent method within the AStarPathfindingAlgorithm. --- .../path/AStarPathfindingAlgorithm.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/org/apollo/game/model/entity/path/AStarPathfindingAlgorithm.java b/src/org/apollo/game/model/entity/path/AStarPathfindingAlgorithm.java index 12c0d410..eb06d263 100644 --- a/src/org/apollo/game/model/entity/path/AStarPathfindingAlgorithm.java +++ b/src/org/apollo/game/model/entity/path/AStarPathfindingAlgorithm.java @@ -71,7 +71,7 @@ final class AStarPathfindingAlgorithm extends PathfindingAlgorithm { Position adjacent = new Position(nextX, nextY); if (traversable(adjacent)) { - Node node = createIfAbsent(adjacent, nodes); + Node node = nodes.computeIfAbsent(adjacent, Node::new); compare(active, node, open, sorted, heuristic); } } @@ -118,24 +118,6 @@ final class AStarPathfindingAlgorithm extends PathfindingAlgorithm { } } - /** - * Creates a {@link Node} and inserts it into the specified {@link Map} if one does not already exist, then returns - * that node. - * - * @param position The {@link Position}. - * @param nodes The map of positions to nodes. - * @return The node. - */ - private Node createIfAbsent(Position position, Map nodes) { - Node existing = nodes.get(position); - if (existing == null) { - existing = new Node(position); - nodes.put(position, existing); - } - - return existing; - } - /** * Gets the cheapest open {@link Node} from the {@link Queue}. *