We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8c95f55 commit 5e91ac1Copy full SHA for 5e91ac1
src/libstd/rt/mpmc_bounded_queue.rs
@@ -57,8 +57,12 @@ struct Queue<T> {
57
impl<T: Send> State<T> {
58
fn with_capacity(capacity: uint) -> State<T> {
59
let capacity = if capacity < 2 || (capacity & (capacity - 1)) != 0 {
60
- // use next power of 2 as capacity
61
- 2f64.pow(&((capacity as f64).log2().floor()+1f64)) as uint
+ if capacity < 2 {
+ 2u
62
+ } else {
63
+ // use next power of 2 as capacity
64
+ 2f64.pow(&((capacity as f64).log2().ceil())) as uint
65
+ }
66
} else {
67
capacity
68
};
0 commit comments