about summary refs log tree commit diff
path: root/src/libstd/rt/mpmc_bounded_queue.rs
diff options
context:
space:
mode:
authorJason Toffaletti <jason@topsy.com>2013-10-08 08:09:13 -0700
committerBrian Anderson <banderson@mozilla.com>2013-10-25 18:27:46 -0700
commit5e91ac10b65a4c20915868d3af3c06f1d3d3cada (patch)
tree2e0dde81c2dd3f81307e4f501dfcdc1ee8fdb27b /src/libstd/rt/mpmc_bounded_queue.rs
parent8c95f558d0f3acb5ea301acb631d0d616d61c7b6 (diff)
downloadrust-5e91ac10b65a4c20915868d3af3c06f1d3d3cada.tar.gz
rust-5e91ac10b65a4c20915868d3af3c06f1d3d3cada.zip
minor
Diffstat (limited to 'src/libstd/rt/mpmc_bounded_queue.rs')
-rw-r--r--src/libstd/rt/mpmc_bounded_queue.rs8
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
         };