Skip to content

Commit

Permalink
refactor(client): use some api instead of manual implementaion
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Jan 14, 2024
1 parent 2c4d2fc commit eb66ff2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ fn set_scheme(uri: &mut Uri, scheme: Scheme) {
uri.scheme().is_none(),
"set_scheme expects no existing scheme"
);
let old = std::mem::replace(uri, Uri::default());
let old = std::mem::take(uri);
let mut parts: ::http::uri::Parts = old.into();
parts.scheme = Some(scheme);
parts.path_and_query = Some("/".parse().expect("slash is a valid path"));
Expand Down
4 changes: 1 addition & 3 deletions src/client/legacy/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,7 @@ struct ConnectingTcpRemote {

impl ConnectingTcpRemote {
fn new(addrs: dns::SocketAddrs, connect_timeout: Option<Duration>) -> Self {
let connect_timeout = connect_timeout
.map(|t| t.checked_div(addrs.len() as u32))
.flatten();
let connect_timeout = connect_timeout.and_then(|t| t.checked_div(addrs.len() as u32));

Self {
addrs,
Expand Down
2 changes: 1 addition & 1 deletion src/client/legacy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl<T: Poolable, K: Key> PoolInner<T, K> {
Some(value) => {
// borrow-check scope...
{
let idle_list = self.idle.entry(key.clone()).or_insert_with(Vec::new);
let idle_list = self.idle.entry(key.clone()).or_default();
if self.max_idle_per_host <= idle_list.len() {
trace!("max idle per host for {:?}, dropping connection", key);
return;
Expand Down

0 comments on commit eb66ff2

Please sign in to comment.