Skip to content

Commit

Permalink
Add vec!['\0'; n] optimization, like vec![0; n]
Browse files Browse the repository at this point in the history
Similarly to vec![ptr::null{,_mut}(); n] in previous change, this adds
the optimization for vec!['\0'; n].
  • Loading branch information
glandium committed Apr 2, 2018
1 parent cc939ac commit 0df837f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,8 @@ impl_is_zero!(u64, |x| x == 0);
impl_is_zero!(u128, |x| x == 0);
impl_is_zero!(usize, |x| x == 0);

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

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

Expand Down

0 comments on commit 0df837f

Please sign in to comment.