Skip to content

Commit 5e91ac1

Browse files
toffalettibrson
authored andcommitted
minor
1 parent 8c95f55 commit 5e91ac1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libstd/rt/mpmc_bounded_queue.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ struct Queue<T> {
5757
impl<T: Send> State<T> {
5858
fn with_capacity(capacity: uint) -> State<T> {
5959
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
60+
if capacity < 2 {
61+
2u
62+
} else {
63+
// use next power of 2 as capacity
64+
2f64.pow(&((capacity as f64).log2().ceil())) as uint
65+
}
6266
} else {
6367
capacity
6468
};

0 commit comments

Comments
 (0)