Skip to content

Commit 74ec42e

Browse files
committed
refactor confusing loop in proc_macro arena
1 parent 0a6462b commit 74ec42e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

library/proc_macro/src/bridge/arena.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,13 @@ impl Arena {
9090
return &mut [];
9191
}
9292

93-
loop {
94-
if let Some(a) = self.alloc_raw_without_grow(bytes) {
95-
break a;
96-
}
97-
// No free space left. Allocate a new chunk to satisfy the request.
98-
// On failure the grow will panic or abort.
99-
self.grow(bytes);
93+
if let Some(a) = self.alloc_raw_without_grow(bytes) {
94+
return a;
10095
}
96+
// No free space left. Allocate a new chunk to satisfy the request.
97+
// On failure the grow will panic or abort.
98+
self.grow(bytes);
99+
self.alloc_raw_without_grow(bytes).unwrap()
101100
}
102101

103102
#[allow(clippy::mut_from_ref)] // arena allocator

0 commit comments

Comments
 (0)