diff --git a/squangle/logger/DBEventCounter.cpp b/squangle/logger/DBEventCounter.cpp index d376fc9..13fedc2 100644 --- a/squangle/logger/DBEventCounter.cpp +++ b/squangle/logger/DBEventCounter.cpp @@ -16,7 +16,7 @@ namespace facebook { namespace db { void ConnectionContextBase::collectNormalValues( - AddNormalValueFunction add) const { + const AddNormalValueFunction& add) const { add("is_ssl", folly::to(isSslConnection)); add("is_ssl_session_reused", folly::to(sslSessionReused)); if (!sslVersion.empty()) { @@ -37,7 +37,8 @@ void ConnectionContextBase::collectNormalValues( } } -void ConnectionContextBase::collectIntValues(AddIntValueFunction add) const { +void ConnectionContextBase::collectIntValues( + const AddIntValueFunction& add) const { add("ssl_server_cert_validated", isServerCertValidated ? 1 : 0); add("ssl_client_identity_cert", isIdentityClientCert ? 1 : 0); if (certCacheSize.has_value()) { diff --git a/squangle/logger/DBEventCounter.h b/squangle/logger/DBEventCounter.h index ba98101..75809e6 100644 --- a/squangle/logger/DBEventCounter.h +++ b/squangle/logger/DBEventCounter.h @@ -30,8 +30,8 @@ using AddIntValueFunction = class ConnectionContextBase { public: virtual ~ConnectionContextBase() {} - virtual void collectNormalValues(AddNormalValueFunction add) const; - virtual void collectIntValues(AddIntValueFunction add) const; + virtual void collectNormalValues(const AddNormalValueFunction& add) const; + virtual void collectIntValues(const AddIntValueFunction& add) const; virtual std::unique_ptr copy() const { return std::make_unique(*this); } diff --git a/squangle/mysql_client/AsyncConnectionPool.cpp b/squangle/mysql_client/AsyncConnectionPool.cpp index 3b8dd84..de91bef 100644 --- a/squangle/mysql_client/AsyncConnectionPool.cpp +++ b/squangle/mysql_client/AsyncConnectionPool.cpp @@ -195,7 +195,7 @@ std::ostream& operator<<(std::ostream& os, const PoolOptions& options) { << ",pool per instance:" << options.poolPerMysqlInstance() << "}"; } -std::ostream& operator<<(std::ostream& os, PoolKey key) { +std::ostream& operator<<(std::ostream& os, const PoolKey& key) { return os << "{key:" << key.connKey.getDisplayString() << ",options:" << key.connOptions.getDisplayString() << "}"; } diff --git a/squangle/mysql_client/DbResult.cpp b/squangle/mysql_client/DbResult.cpp index bb83b7f..ebce65d 100644 --- a/squangle/mysql_client/DbResult.cpp +++ b/squangle/mysql_client/DbResult.cpp @@ -206,7 +206,7 @@ void StreamedQueryResult::setResult( } void StreamedQueryResult::setException(folly::exception_wrapper ex) { - exception_wrapper_ = ex; + exception_wrapper_ = std::move(ex); } void StreamedQueryResult::freeHandler() { @@ -215,7 +215,7 @@ void StreamedQueryResult::freeHandler() { MultiQueryStreamHandler::MultiQueryStreamHandler( std::shared_ptr op) - : operation_(op) {} + : operation_(std::move(op)) {} folly::Optional MultiQueryStreamHandler::nextQuery() { if (state_ == State::RunQuery) { diff --git a/squangle/mysql_client/PoolKey.h b/squangle/mysql_client/PoolKey.h index a2349a3..76c1311 100644 --- a/squangle/mysql_client/PoolKey.h +++ b/squangle/mysql_client/PoolKey.h @@ -70,7 +70,7 @@ struct PoolKeyStats { size_t connection_limit; }; -std::ostream& operator<<(std::ostream& os, PoolKey key); +std::ostream& operator<<(std::ostream& os, const PoolKey& key); class PoolKeyHash { public: diff --git a/squangle/mysql_client/Query.cpp b/squangle/mysql_client/Query.cpp index 2afbadf..5271e9c 100644 --- a/squangle/mysql_client/Query.cpp +++ b/squangle/mysql_client/Query.cpp @@ -41,15 +41,17 @@ QueryArgument::QueryArgument(folly::fbstring&& val) : value_(std::move(val)) {} QueryArgument::QueryArgument(double double_val) : value_(double_val) {} -QueryArgument::QueryArgument(std::initializer_list list) +QueryArgument::QueryArgument(const std::initializer_list& list) : value_(std::vector(list.begin(), list.end())) {} QueryArgument::QueryArgument(std::vector arg_list) - : value_(std::vector(arg_list.begin(), arg_list.end())) {} + : value_(std::move(arg_list)) {} QueryArgument::QueryArgument() : value_(std::vector()) {} -QueryArgument::QueryArgument(folly::StringPiece param1, QueryArgument param2) +QueryArgument::QueryArgument( + folly::StringPiece param1, + const QueryArgument& param2) : value_(std::vector()) { getPairs().emplace_back(ArgPair(param1.str(), param2)); } @@ -223,7 +225,9 @@ std::vector& QueryArgument::getPairs() { Query::Query( const folly::StringPiece query_text, std::vector params) - : query_text_(query_text), unsafe_query_(false), params_(params) {} + : query_text_(query_text), + unsafe_query_(false), + params_(std::move(params)) {} Query::~Query() {} diff --git a/squangle/mysql_client/Query.h b/squangle/mysql_client/Query.h index 608b9be..f9e3c22 100644 --- a/squangle/mysql_client/Query.h +++ b/squangle/mysql_client/Query.h @@ -423,7 +423,8 @@ class QueryArgument { : value_(static_cast(enum_val)) {} /* implicit */ QueryArgument(double double_val); - /* implicit */ QueryArgument(std::initializer_list list); + /* implicit */ QueryArgument( + const std::initializer_list& list); /* implicit */ QueryArgument(std::vector arg_list); /* implicit */ QueryArgument(std::tuple tup) : value_(tup) {} @@ -488,7 +489,7 @@ class QueryArgument { // Pair constructors QueryArgument(); - QueryArgument(folly::StringPiece param1, QueryArgument param2); + QueryArgument(folly::StringPiece param1, const QueryArgument& param2); // Since we already have callsites that use dynamic, we are keeping the // support, but internally we unpack them. diff --git a/squangle/mysql_client/SyncMysqlClient.cpp b/squangle/mysql_client/SyncMysqlClient.cpp index 7371efd..0727f65 100644 --- a/squangle/mysql_client/SyncMysqlClient.cpp +++ b/squangle/mysql_client/SyncMysqlClient.cpp @@ -25,7 +25,8 @@ std::shared_ptr SyncMysqlClient::defaultClient() { std::unique_ptr SyncMysqlClient::createConnection( ConnectionKey conn_key, MYSQL* mysql_conn) { - return std::make_unique(this, conn_key, mysql_conn); + return std::make_unique( + this, std::move(conn_key), mysql_conn); } SyncConnection::~SyncConnection() {