Skip to content

Commit 3d7f8cc

Browse files
Nicholas Maccharolimoiseev
authored andcommitted
[stdlib] Reorder increment and element creation to not need (#5062)
1 parent 32634b1 commit 3d7f8cc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

stdlib/public/core/Algorithm.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ public struct EnumeratedIterator<
106106
/// Once `nil` has been returned, all subsequent calls return `nil`.
107107
public mutating func next() -> Element? {
108108
guard let b = _base.next() else { return nil }
109-
defer { _count += 1 }
110-
return (offset: _count, element: b)
109+
let result = (offset: _count, element: b)
110+
_count += 1
111+
return result
111112
}
112113
}
113114

0 commit comments

Comments
 (0)