Skip to content

Commit

Permalink
Fix unnecessary copies
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Nov 17, 2023
1 parent d402e8a commit 4b23573
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/tao/pq/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions include/tao/pq/connection_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pq/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 );
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pq/connection_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down

0 comments on commit 4b23573

Please sign in to comment.