Skip to content

Commit

Permalink
Apply rustfmt on liballoc folder
Browse files Browse the repository at this point in the history
  • Loading branch information
srinivasreddy committed Oct 18, 2016
1 parent 16eeeac commit 434c58e
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/liballoc/raw_vec.rs
Expand Up @@ -57,11 +57,7 @@ impl<T> RawVec<T> {
pub fn new() -> Self {
unsafe {
// !0 is usize::MAX. This branch should be stripped at compile time.
let cap = if mem::size_of::<T>() == 0 {
!0
} else {
0
};
let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };

// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
RawVec {
Expand Down Expand Up @@ -209,11 +205,7 @@ impl<T> RawVec<T> {

let (new_cap, ptr) = if self.cap == 0 {
// skip to 4 because tiny Vec's are dumb; but not if that would cause overflow
let new_cap = if elem_size > (!0) / 8 {
1
} else {
4
};
let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 };
let ptr = heap::allocate(new_cap * elem_size, align);
(new_cap, ptr)
} else {
Expand Down Expand Up @@ -347,7 +339,7 @@ impl<T> RawVec<T> {
let elem_size = mem::size_of::<T>();
// Nothing we can really do about these checks :(
let required_cap = used_cap.checked_add(needed_extra_cap)
.expect("capacity overflow");
.expect("capacity overflow");
// Cannot overflow, because `cap <= isize::MAX`, and type of `cap` is `usize`.
let double_cap = self.cap * 2;
// `double_cap` guarantees exponential growth.
Expand Down

0 comments on commit 434c58e

Please sign in to comment.