Skip to content

Commit b8d936a

Browse files
committed
Remove effective 'goto' with better style
1 parent ef5b8ad commit b8d936a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

A-Star/AStar.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ public final class AStar<G: Graph> {
5454
/// - Precondition: both `source` and `target` belong to `graph`.
5555
public func path(start: G.Vertex, target: G.Vertex) -> [G.Vertex] {
5656
open.insert(Node<G.Vertex>(vertex: start, cost: 0, estimate: heuristic(start, target)))
57-
while !open.isEmpty {
58-
guard let node = open.remove() else {
59-
break
60-
}
57+
while !open.isEmpty, let node = open.remove() {
6158
costs[node.vertex] = node.cost
6259

6360
if (node.vertex == target) {

0 commit comments

Comments
 (0)