Skip to content

Commit 0d05042

Browse files
mdznrTim Vermeulen
and
Tim Vermeulen
committed
Avoid double-checking finished/empty case
Co-authored-by: Tim Vermeulen <tvermeulen@apple.com>
1 parent 3d3296e commit 0d05042

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Diff for: Sources/Algorithms/Permutations.swift

+2-5
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,8 @@ extension Permutations: Sequence {
149149
/// Advances `kRange` by incrementing its `lowerBound` until the range is
150150
/// empty, when iteration is finished.
151151
func advanceKRange() {
152-
if kRange.lowerBound < kRange.upperBound {
153-
let advancedLowerBound = kRange.lowerBound + 1
154-
kRange = advancedLowerBound ..< kRange.upperBound
155-
indexes = Array(base.indices)
156-
}
152+
kRange.removeFirst()
153+
indexes = Array(base.indices)
157154
}
158155

159156
let countToChoose = self.kRange.lowerBound

0 commit comments

Comments
 (0)