From ff9646c0adc149dfff194665785f4daa3aa6d9c3 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Mon, 11 May 2020 17:19:25 -0700 Subject: Stabilize process_set_argv0 feature for Unix This stabilizes process_set_argv0 targeting 1.45.0. It has been useful in practice and seems useful as-is. The equivalent feature could be implemented for Windows, but as far as I know nobody has. That can be done separately. Tracking issue: #66510 --- src/libstd/sys/unix/ext/process.rs | 2 +- src/libstd/sys/vxworks/ext/process.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index fa8670b4aec..048ce24d6ba 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -111,7 +111,7 @@ pub trait CommandExt { /// /// Set the first process argument, `argv[0]`, to something other than the /// default executable path. - #[unstable(feature = "process_set_argv0", issue = "66510")] + #[stable(feature = "process_set_argv0", since = "1.45.0")] fn arg0(&mut self, arg: S) -> &mut process::Command where S: AsRef; diff --git a/src/libstd/sys/vxworks/ext/process.rs b/src/libstd/sys/vxworks/ext/process.rs index 31e691dd136..c3710f4b912 100644 --- a/src/libstd/sys/vxworks/ext/process.rs +++ b/src/libstd/sys/vxworks/ext/process.rs @@ -111,7 +111,7 @@ pub trait CommandExt { /// /// Set the first process argument, `argv[0]`, to something other than the /// default executable path. - #[unstable(feature = "process_set_argv0", issue = "66510")] + #[stable(feature = "process_set_argv0", since = "1.45.0")] fn arg0(&mut self, arg: S) -> &mut process::Command where S: AsRef; -- cgit 1.4.1-3-g733a5 From dc3de7cb2ae9d886ddac91d71f2e9517ff123e90 Mon Sep 17 00:00:00 2001 From: Nathan West Date: Wed, 20 May 2020 16:49:31 -0400 Subject: Add fast-path optimization for Ipv4Addr::fmt --- src/libstd/net/ip.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index edc28033c9b..6e2478b8308 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -856,16 +856,23 @@ impl From for IpAddr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Ipv4Addr { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - const IPV4_BUF_LEN: usize = 15; // Long enough for the longest possible IPv4 address - let mut buf = [0u8; IPV4_BUF_LEN]; - let mut buf_slice = &mut buf[..]; let octets = self.octets(); - // Note: The call to write should never fail, hence the unwrap - write!(buf_slice, "{}.{}.{}.{}", octets[0], octets[1], octets[2], octets[3]).unwrap(); - let len = IPV4_BUF_LEN - buf_slice.len(); - // This unsafe is OK because we know what is being written to the buffer - let buf = unsafe { crate::str::from_utf8_unchecked(&buf[..len]) }; - fmt.pad(buf) + // Fast Path: if there's no alignment stuff, write directly to the buffer + if fmt.precision().is_none() && fmt.width().is_none() { + write!(fmt, "{}.{}.{}.{}", octets[0], octets[1], octets[2], octets[3]) + } else { + const IPV4_BUF_LEN: usize = 15; // Long enough for the longest possible IPv4 address + let mut buf = [0u8; IPV4_BUF_LEN]; + let mut buf_slice = &mut buf[..]; + + // Note: The call to write should never fail, hence the unwrap + write!(buf_slice, "{}.{}.{}.{}", octets[0], octets[1], octets[2], octets[3]).unwrap(); + let len = IPV4_BUF_LEN - buf_slice.len(); + + // This unsafe is OK because we know what is being written to the buffer + let buf = unsafe { crate::str::from_utf8_unchecked(&buf[..len]) }; + fmt.pad(buf) + } } } -- cgit 1.4.1-3-g733a5