Skip init on clone

The cloned buffer's content is not observable until written into, so
there is no need to keep it identical to the old buffer's content.
This commit is contained in:
David Tolnay
2020-05-29 21:12:00 -07:00
parent cbff41a2ee
commit 89b4848ec2
+9 -1
View File
@@ -21,7 +21,6 @@ const NEG_INFINITY: &'static str = "-inf";
/// let printed = buffer.format_finite(1.234);
/// assert_eq!(printed, "1.234");
/// ```
#[derive(Copy, Clone)]
pub struct Buffer {
#[cfg(maybe_uninit)]
bytes: [MaybeUninit<u8>; 24],
@@ -93,6 +92,15 @@ impl Buffer {
}
}
impl Copy for Buffer {}
impl Clone for Buffer {
#[inline]
fn clone(&self) -> Self {
Buffer::new()
}
}
impl Default for Buffer {
#[inline]
#[cfg_attr(feature = "no-panic", no_panic)]