diff --git a/include/tao/pq/connection.hpp b/include/tao/pq/connection.hpp index 9972046..1c67486 100644 --- a/include/tao/pq/connection.hpp +++ b/include/tao/pq/connection.hpp @@ -99,7 +99,7 @@ namespace tao::pq }; public: - connection( const private_key /*unused*/, const std::string& connection_info, const std::function< poll::callback > poll_cb ); + connection( const private_key /*unused*/, const std::string& connection_info, const std::function< poll::callback >& poll_cb ); connection( const connection& ) = delete; connection( connection&& ) = delete; @@ -108,7 +108,7 @@ namespace tao::pq ~connection() = default; - [[nodiscard]] static auto create( const std::string& connection_info, const std::function< poll::callback > poll_cb = poll::internal::default_poll ) -> std::shared_ptr< connection >; + [[nodiscard]] static auto create( const std::string& connection_info, const std::function< poll::callback >& poll_cb = poll::internal::default_poll ) -> std::shared_ptr< connection >; [[nodiscard]] auto error_message() const -> std::string; diff --git a/include/tao/pq/connection_pool.hpp b/include/tao/pq/connection_pool.hpp index 45ef968..beed92f 100644 --- a/include/tao/pq/connection_pool.hpp +++ b/include/tao/pq/connection_pool.hpp @@ -43,9 +43,9 @@ namespace tao::pq }; public: - connection_pool( const private_key /*unused*/, const std::string_view connection_info, const std::function< poll::callback > poll_cb ); + connection_pool( const private_key /*unused*/, const std::string_view connection_info, const std::function< poll::callback >& poll_cb ); - [[nodiscard]] static auto create( const std::string_view connection_info, const std::function< poll::callback > poll_cb = poll::internal::default_poll ) -> std::shared_ptr< connection_pool >; + [[nodiscard]] static auto create( const std::string_view connection_info, const std::function< poll::callback >& poll_cb = poll::internal::default_poll ) -> std::shared_ptr< connection_pool >; [[nodiscard]] auto timeout() const noexcept -> decltype( auto ) { diff --git a/src/lib/pq/connection.cpp b/src/lib/pq/connection.cpp index 9ae2655..5d4667c 100644 --- a/src/lib/pq/connection.cpp +++ b/src/lib/pq/connection.cpp @@ -378,7 +378,7 @@ namespace tao::pq } } - connection::connection( const private_key /*unused*/, const std::string& connection_info, const std::function< poll::callback > poll_cb ) + connection::connection( const private_key /*unused*/, const std::string& connection_info, const std::function< poll::callback >& poll_cb ) : m_pgconn( PQconnectdb( connection_info.c_str() ), &PQfinish ), m_current_transaction( nullptr ), m_poll( poll_cb ) @@ -394,7 +394,7 @@ namespace tao::pq } } - auto connection::create( const std::string& connection_info, const std::function< poll::callback > poll_cb ) -> std::shared_ptr< connection > + auto connection::create( const std::string& connection_info, const std::function< poll::callback >& poll_cb ) -> std::shared_ptr< connection > { return std::make_shared< connection >( private_key(), connection_info, poll_cb ); } diff --git a/src/lib/pq/connection_pool.cpp b/src/lib/pq/connection_pool.cpp index feb7e94..89dc6f6 100644 --- a/src/lib/pq/connection_pool.cpp +++ b/src/lib/pq/connection_pool.cpp @@ -11,12 +11,12 @@ namespace tao::pq return std::make_unique< pq::connection >( pq::connection::private_key(), m_connection_info, m_poll ); } - connection_pool::connection_pool( const private_key /*unused*/, const std::string_view connection_info, const std::function< poll::callback > poll_cb ) + connection_pool::connection_pool( const private_key /*unused*/, const std::string_view connection_info, const std::function< poll::callback >& poll_cb ) : m_connection_info( connection_info ), m_poll( poll_cb ) {} - auto connection_pool::create( const std::string_view connection_info, const std::function< poll::callback > poll_cb ) -> std::shared_ptr< connection_pool > + auto connection_pool::create( const std::string_view connection_info, const std::function< poll::callback >& poll_cb ) -> std::shared_ptr< connection_pool > { return std::make_shared< connection_pool >( private_key(), connection_info, poll_cb ); }