Skip to content

Commit ee65811

Browse files
author
zach-com
committed
Avoid unnecessary function call
1 parent f655c3b commit ee65811

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

postgres/src/client.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,11 @@ impl Client {
416416

417417
/// Validates connection, timing out after specified duration.
418418
pub fn is_valid(&mut self, timeout: Duration) -> Result<(), Error> {
419-
let is_valid = Client::is_valid_inner(&self.client, timeout);
420-
self.connection.block_on(is_valid)
421-
}
422-
423-
async fn is_valid_inner(client: &tokio_postgres::Client, timeout: Duration) -> Result<(), Error> {
424-
let trivial_query = client.simple_query("");
425-
tokio::time::timeout(timeout, trivial_query).await?.map(|_| ())
419+
let inner_client = &self.client;
420+
self.connection.block_on(async {
421+
let trivial_query = inner_client.simple_query("");
422+
tokio::time::timeout(timeout, trivial_query).await?.map(|_| ())
423+
})
426424
}
427425

428426
/// Executes a sequence of SQL statements using the simple query protocol.

0 commit comments

Comments
 (0)