From ee65811272ff221b6fcf605ef84507a02c2107c1 Mon Sep 17 00:00:00 2001 From: zach-com <54674467+zach-com@users.noreply.github.com> Date: Wed, 16 Dec 2020 15:56:16 -0500 Subject: [PATCH] Avoid unnecessary function call --- postgres/src/client.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/postgres/src/client.rs b/postgres/src/client.rs index fcd7f772..f34cffe1 100644 --- a/postgres/src/client.rs +++ b/postgres/src/client.rs @@ -416,13 +416,11 @@ impl Client { /// Validates connection, timing out after specified duration. pub fn is_valid(&mut self, timeout: Duration) -> Result<(), Error> { - let is_valid = Client::is_valid_inner(&self.client, timeout); - self.connection.block_on(is_valid) - } - - async fn is_valid_inner(client: &tokio_postgres::Client, timeout: Duration) -> Result<(), Error> { - let trivial_query = client.simple_query(""); - tokio::time::timeout(timeout, trivial_query).await?.map(|_| ()) + let inner_client = &self.client; + self.connection.block_on(async { + let trivial_query = inner_client.simple_query(""); + tokio::time::timeout(timeout, trivial_query).await?.map(|_| ()) + }) } /// Executes a sequence of SQL statements using the simple query protocol.