diff options
| -rw-r--r-- | src/libstd/rt/mpmc_bounded_queue.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstd/rt/mpmc_bounded_queue.rs b/src/libstd/rt/mpmc_bounded_queue.rs index c0c7d281136..ea5d1050c18 100644 --- a/src/libstd/rt/mpmc_bounded_queue.rs +++ b/src/libstd/rt/mpmc_bounded_queue.rs @@ -57,8 +57,12 @@ struct Queue<T> { impl<T: Send> State<T> { fn with_capacity(capacity: uint) -> State<T> { let capacity = if capacity < 2 || (capacity & (capacity - 1)) != 0 { - // use next power of 2 as capacity - 2f64.pow(&((capacity as f64).log2().floor()+1f64)) as uint + if capacity < 2 { + 2u + } else { + // use next power of 2 as capacity + 2f64.pow(&((capacity as f64).log2().ceil())) as uint + } } else { capacity }; |
