Skip to content

Commit bbccbd3

Browse files
authored
Merge pull request #66179 from Mayank-84/Refactor/Stacks
[Optimizer] Refactored the `Stack.swift` file to make it more readable and concise. 🚀
2 parents 4fc0be2 + 58ad356 commit bbccbd3

File tree

1 file changed

+10
-10
lines changed
  • SwiftCompilerSources/Sources/Optimizer/DataStructures

1 file changed

+10
-10
lines changed

SwiftCompilerSources/Sources/Optimizer/DataStructures/Stack.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ struct Stack<Element> : CollectionLikeSequence {
4747

4848
mutating func next() -> Element? {
4949
let end = (slab.data == lastSlab.data ? endIndex : slabCapacity)
50-
if index < end {
51-
let elem = Stack.bind(slab)[index]
52-
index += 1
53-
54-
if index >= end && slab.data != lastSlab.data {
55-
slab = slab.getNext()
56-
index = 0
57-
}
58-
return elem
50+
51+
guard index < end else { return nil }
52+
53+
let elem = Stack.bind(slab)[index]
54+
index += 1
55+
56+
if index >= end && slab.data != lastSlab.data {
57+
slab = slab.getNext()
58+
index = 0
5959
}
60-
return nil
60+
return elem
6161
}
6262
}
6363

0 commit comments

Comments
 (0)