Skip to content

Commit 5dbf93b

Browse files
authored
Replace loop with while (#407)
1 parent 806ecaa commit 5dbf93b

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/source/buffered.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,14 @@ where
7878
// solves the problem, as when the time comes to actually deallocate the `FrameData`,
7979
// the `next` field will contain a `Frame::End`, or an `Arc` with additional references,
8080
// so the depth of recursive drops will be bounded.
81-
loop {
82-
if let Ok(arc_next) = self.next.get_mut() {
83-
if let Some(next_ref) = Arc::get_mut(arc_next) {
84-
// This allows us to own the next Frame.
85-
let next = mem::replace(next_ref, Frame::End);
86-
if let Frame::Data(next_data) = next {
87-
// Swap the current FrameData with the next one, allowing the current one
88-
// to go out of scope.
89-
*self = next_data;
90-
} else {
91-
break;
92-
}
81+
while let Ok(arc_next) = self.next.get_mut() {
82+
if let Some(next_ref) = Arc::get_mut(arc_next) {
83+
// This allows us to own the next Frame.
84+
let next = mem::replace(next_ref, Frame::End);
85+
if let Frame::Data(next_data) = next {
86+
// Swap the current FrameData with the next one, allowing the current one
87+
// to go out of scope.
88+
*self = next_data;
9389
} else {
9490
break;
9591
}

0 commit comments

Comments
 (0)