diff --git a/Cargo.lock b/Cargo.lock index 89ca8fc..80ed202 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1415,6 +1415,7 @@ dependencies = [ "hickory-resolver", "http", "httpdate", + "itoa", "log", "maxminddb", "mimalloc", diff --git a/Cargo.toml b/Cargo.toml index 0cdcea4..addaa10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ publish = false async-trait = "=0.1.89" color-eyre = "=0.6.5" compact_str = { version = "=0.9.0", features = ["serde"] } +itoa = "=1.0.16" crossterm = { version = "=0.28.1", default-features = false, features = [ "event-stream", "windows", diff --git a/src/proxy.rs b/src/proxy.rs index bafe436..381a017 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -1,5 +1,4 @@ use std::{ - fmt::Write as _, hash::{Hash, Hasher}, str::FromStr, sync::Arc, @@ -139,16 +138,22 @@ impl Proxy { let mut s = compact_str::CompactString::const_new(""); if include_protocol { - write!(s, "{}://", self.protocol.as_str()).unwrap(); + s.push_str(self.protocol.as_str()); + s.push_str("://"); } if let (Some(username), Some(password)) = (&self.username, &self.password) { - write!(s, "{username}:{password}@").unwrap(); + s.push_str(username); + s.push(':'); + s.push_str(password); + s.push('@'); } - write!(s, "{}:{}", self.host, self.port).unwrap(); + s.push_str(&self.host); + s.push(':'); + s.push_str(itoa::Buffer::new().format(self.port)); s } diff --git a/src/utils.rs b/src/utils.rs index 608325f..67c2793 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -32,7 +32,8 @@ pub trait CompactStrJoin: Iterator { ); write!(&mut result, "{first_elt}").unwrap(); for elt in self { - write!(&mut result, "{sep}{elt}").unwrap(); + result.push_str(sep); + write!(&mut result, "{elt}").unwrap(); } result },