Skip to content

Commit

Permalink
Optimise vec![false; N] to zero-alloc
Browse files Browse the repository at this point in the history
Nowadays booleans have a well-defined representation, so there is no reason not to optimise their allocation.
  • Loading branch information
RReverser committed Feb 21, 2019
1 parent 1349c84 commit 9f58c5f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ impl_is_zero!(u64, |x| x == 0);
impl_is_zero!(u128, |x| x == 0);
impl_is_zero!(usize, |x| x == 0);

impl_is_zero!(bool, |x| x == false);
impl_is_zero!(char, |x| x == '\0');

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

0 comments on commit 9f58c5f

Please sign in to comment.