fix: add itoa dependency and optimize string formatting in Proxy implementation

This commit is contained in:
monosans
2025-12-24 13:31:29 +03:00
parent 843c9f3553
commit 44c1a8f177
4 changed files with 13 additions and 5 deletions
+9 -4
View File
@@ -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
}