diff options
| author | bors <bors@rust-lang.org> | 2016-10-21 20:29:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-21 20:29:25 -0700 |
| commit | f136e9e2995c7682ab0c89a93cc197a246eaea81 (patch) | |
| tree | 061aaed5771f060ee9c6dd415b17a9228adcec7b /src/liballoc | |
| parent | a6fa57291b2a4e94da00cb078fb7f9f3366bc9cb (diff) | |
| parent | 1c2d2235c976a14c4e17e9d258e3e0a500078409 (diff) | |
| download | rust-f136e9e2995c7682ab0c89a93cc197a246eaea81.tar.gz rust-f136e9e2995c7682ab0c89a93cc197a246eaea81.zip | |
Auto merge of #37337 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 10 pull requests - Successful merges: #37043, #37209, #37211, #37219, #37244, #37253, #37286, #37297, #37309, #37314 - Failed merges:
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/raw_vec.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index e153507956b..f23ea0ea8bf 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -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 { @@ -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 { @@ -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. |
