Skip to content

Commit

Permalink
refactor(client): use Box<str> inside dns::Name (hyperium#2727)
Browse files Browse the repository at this point in the history
Use Box<str> in hyper::client::connect::dns::Name, so
its size is 16 bytes, not 24 bytes.  As Name never
change its contents, read-only Box<str> is perfectly OK.
  • Loading branch information
monoid authored Dec 29, 2021
1 parent 02f3630 commit f1b89c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/client/connect/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(super) use self::sealed::Resolve;
/// A domain name to resolve into IP addresses.
#[derive(Clone, Hash, Eq, PartialEq)]
pub struct Name {
host: String,
host: Box<str>,
}

/// A resolver using blocking `getaddrinfo` calls in a threadpool.
Expand All @@ -58,7 +58,7 @@ pub struct GaiFuture {
}

impl Name {
pub(super) fn new(host: String) -> Name {
pub(super) fn new(host: Box<str>) -> Name {
Name { host }
}

Expand All @@ -85,7 +85,7 @@ impl FromStr for Name {

fn from_str(host: &str) -> Result<Self, Self::Err> {
// Possibly add validation later
Ok(Name::new(host.to_owned()))
Ok(Name::new(host.into()))
}
}

Expand Down

0 comments on commit f1b89c1

Please sign in to comment.