Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,21 @@ impl<T: Clone> SpecFromElem for T {
}
}

impl SpecFromElem for i8 {
#[inline]
fn from_elem(elem: i8, n: usize) -> Vec<i8> {
if elem == 0 {
return Vec { buf: RawVec::with_capacity_zeroed(n), len: n };
}
unsafe {
let mut v = Vec::with_capacity(n);
ptr::write_bytes(v.as_mut_ptr(), elem as u8, n);
v.set_len(n);
v
}
}
}

impl SpecFromElem for u8 {
#[inline]
fn from_elem(elem: u8, n: usize) -> Vec<u8> {
Expand Down Expand Up @@ -1847,7 +1862,6 @@ macro_rules! impl_is_zero {
};
}

impl_is_zero!(i8, |x| x == 0);
impl_is_zero!(i16, |x| x == 0);
impl_is_zero!(i32, |x| x == 0);
impl_is_zero!(i64, |x| x == 0);
Expand Down