Skip to content

Commit 93bfa92

Browse files
authored
Rollup merge of rust-lang#58628 - RReverser:optimise-vec-false, r=oli-obk
Optimise vec![false; N] to zero-alloc Nowadays booleans have a well-defined representation, so there is no reason not to optimise their allocation.
2 parents 8ccda24 + 9f58c5f commit 93bfa92

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/liballoc/vec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,7 @@ impl_is_zero!(u64, |x| x == 0);
16101610
impl_is_zero!(u128, |x| x == 0);
16111611
impl_is_zero!(usize, |x| x == 0);
16121612

1613+
impl_is_zero!(bool, |x| x == false);
16131614
impl_is_zero!(char, |x| x == '\0');
16141615

16151616
impl_is_zero!(f32, |x: f32| x.to_bits() == 0);

0 commit comments

Comments
 (0)