Skip to content

Commit c0e1098

Browse files
authored
bugfix: Remove the heap allocation from non-single queues
1 parent 22b5e83 commit c0e1098

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ extern crate alloc;
5757
#[cfg(feature = "std")]
5858
extern crate std;
5959

60-
use alloc::boxed::Box;
6160
use core::fmt;
6261
use core::panic::{RefUnwindSafe, UnwindSafe};
6362
use sync::atomic::{self, Ordering};
@@ -101,10 +100,11 @@ unsafe impl<T: Send> Sync for ConcurrentQueue<T> {}
101100
impl<T> UnwindSafe for ConcurrentQueue<T> {}
102101
impl<T> RefUnwindSafe for ConcurrentQueue<T> {}
103102

103+
#[allow(clippy::large_enum_variant)]
104104
enum Inner<T> {
105105
Single(Single<T>),
106-
Bounded(Box<Bounded<T>>),
107-
Unbounded(Box<Unbounded<T>>),
106+
Bounded(Bounded<T>),
107+
Unbounded(Unbounded<T>),
108108
}
109109

110110
impl<T> ConcurrentQueue<T> {
@@ -127,7 +127,7 @@ impl<T> ConcurrentQueue<T> {
127127
if cap == 1 {
128128
ConcurrentQueue(Inner::Single(Single::new()))
129129
} else {
130-
ConcurrentQueue(Inner::Bounded(Box::new(Bounded::new(cap))))
130+
ConcurrentQueue(Inner::Bounded(Bounded::new(cap)))
131131
}
132132
}
133133

@@ -141,7 +141,7 @@ impl<T> ConcurrentQueue<T> {
141141
/// let q = ConcurrentQueue::<i32>::unbounded();
142142
/// ```
143143
pub fn unbounded() -> ConcurrentQueue<T> {
144-
ConcurrentQueue(Inner::Unbounded(Box::new(Unbounded::new())))
144+
ConcurrentQueue(Inner::Unbounded(Unbounded::new()))
145145
}
146146

147147
/// Attempts to push an item into the queue.

0 commit comments

Comments
 (0)