File tree 1 file changed +3
-11
lines changed
1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,7 @@ impl<T> RawVec<T> {
57
57
pub fn new ( ) -> Self {
58
58
unsafe {
59
59
// !0 is usize::MAX. This branch should be stripped at compile time.
60
- let cap = if mem:: size_of :: < T > ( ) == 0 {
61
- !0
62
- } else {
63
- 0
64
- } ;
60
+ let cap = if mem:: size_of :: < T > ( ) == 0 { !0 } else { 0 } ;
65
61
66
62
// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
67
63
RawVec {
@@ -209,11 +205,7 @@ impl<T> RawVec<T> {
209
205
210
206
let ( new_cap, ptr) = if self . cap == 0 {
211
207
// skip to 4 because tiny Vec's are dumb; but not if that would cause overflow
212
- let new_cap = if elem_size > ( !0 ) / 8 {
213
- 1
214
- } else {
215
- 4
216
- } ;
208
+ let new_cap = if elem_size > ( !0 ) / 8 { 1 } else { 4 } ;
217
209
let ptr = heap:: allocate ( new_cap * elem_size, align) ;
218
210
( new_cap, ptr)
219
211
} else {
@@ -347,7 +339,7 @@ impl<T> RawVec<T> {
347
339
let elem_size = mem:: size_of :: < T > ( ) ;
348
340
// Nothing we can really do about these checks :(
349
341
let required_cap = used_cap. checked_add ( needed_extra_cap)
350
- . expect ( "capacity overflow" ) ;
342
+ . expect ( "capacity overflow" ) ;
351
343
// Cannot overflow, because `cap <= isize::MAX`, and type of `cap` is `usize`.
352
344
let double_cap = self . cap * 2 ;
353
345
// `double_cap` guarantees exponential growth.
You can’t perform that action at this time.
0 commit comments