From 704dd8c7ecedb68161c52329e22141877143ff13 Mon Sep 17 00:00:00 2001
From: Dan Goodliffe <dan@randomdan.homeip.net>
Date: Thu, 17 Mar 2022 19:45:15 +0000
Subject: Lots of pass by value and perfect forwarding optimisations

---
 libodbcpp/odbc-command.h |  6 +++---
 libodbcpp/odbc-error.cpp |  5 +++--
 libodbcpp/odbc-param.cpp | 12 ++++++------
 libodbcpp/odbc-param.h   |  6 +++---
 4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/libodbcpp/odbc-command.h b/libodbcpp/odbc-command.h
index cb9fc77..ac6cb40 100644
--- a/libodbcpp/odbc-command.h
+++ b/libodbcpp/odbc-command.h
@@ -33,10 +33,10 @@ namespace ODBC {
 		void bindParamF(unsigned int i, float val) override;
 
 		void bindParamS(unsigned int i, const Glib::ustring &) override;
-		void bindParamS(unsigned int i, const std::string_view &) override;
+		void bindParamS(unsigned int i, const std::string_view) override;
 
-		void bindParamT(unsigned int i, const boost::posix_time::time_duration &) override;
-		void bindParamT(unsigned int i, const boost::posix_time::ptime &) override;
+		void bindParamT(unsigned int i, const boost::posix_time::time_duration) override;
+		void bindParamT(unsigned int i, const boost::posix_time::ptime) override;
 
 		void bindNull(unsigned int i) override;
 
diff --git a/libodbcpp/odbc-error.cpp b/libodbcpp/odbc-error.cpp
index d2379ae..89f2f59 100644
--- a/libodbcpp/odbc-error.cpp
+++ b/libodbcpp/odbc-error.cpp
@@ -3,17 +3,18 @@
 #include <array>
 #include <compileTimeFormatter.h>
 #include <cstddef>
+#include <utility>
 // IWYU pragma: no_include <boost/test/unit_test.hpp>
 
 namespace AdHoc {
 	StreamWriterT('5') {
 		template<std::size_t l, typename... Pn>
 		static void
-		write(stream & s, const std::array<SQLCHAR, l> & sqlstatus, const Pn &... pn)
+		write(stream & s, const std::array<SQLCHAR, l> & sqlstatus, Pn &&... pn)
 		{
 			static_assert(l > 5);
 			s.write(reinterpret_cast<const char * const>(sqlstatus.data()), 5);
-			StreamWriter::next(s, pn...);
+			StreamWriter::next(s, std::forward<Pn>(pn)...);
 		}
 	};
 }
diff --git a/libodbcpp/odbc-param.cpp b/libodbcpp/odbc-param.cpp
index e69e848..781f103 100644
--- a/libodbcpp/odbc-param.cpp
+++ b/libodbcpp/odbc-param.cpp
@@ -68,10 +68,10 @@ SIMPLEBINDER(double, FloatingPointParam, F)
 SIMPLEBINDER(float, FloatingPointParam, F)
 
 SIMPLEBINDER(const Glib::ustring &, StdStringParam, S)
-SIMPLEBINDER(const std::string_view &, StdStringParam, S)
+SIMPLEBINDER(const std::string_view, StdStringParam, S)
 
-SIMPLEBINDER(const boost::posix_time::ptime &, TimeStampParam, T)
-SIMPLEBINDER(const boost::posix_time::time_duration &, IntervalParam, T)
+SIMPLEBINDER(const boost::posix_time::ptime, TimeStampParam, T)
+SIMPLEBINDER(const boost::posix_time::time_duration, IntervalParam, T)
 
 void
 ODBC::Command::bindNull(unsigned int i)
@@ -94,7 +94,7 @@ ODBC::StdStringParam::operator=(Glib::ustring const & d)
 }
 
 ODBC::StdStringParam &
-ODBC::StdStringParam::operator=(std::string_view const & d)
+ODBC::StdStringParam::operator=(const std::string_view d)
 {
 	const char * addr = data.data();
 	data = d;
@@ -108,7 +108,7 @@ ODBC::StdStringParam::operator=(std::string_view const & d)
 }
 
 ODBC::TimeStampParam &
-ODBC::TimeStampParam::operator=(const boost::posix_time::ptime & d)
+ODBC::TimeStampParam::operator=(const boost::posix_time::ptime d)
 {
 	data.year = static_cast<SQLSMALLINT>(d.date().year());
 	data.month = d.date().month();
@@ -121,7 +121,7 @@ ODBC::TimeStampParam::operator=(const boost::posix_time::ptime & d)
 }
 
 ODBC::IntervalParam &
-ODBC::IntervalParam::operator=(const boost::posix_time::time_duration & d)
+ODBC::IntervalParam::operator=(const boost::posix_time::time_duration d)
 {
 	data.interval_type = SQL_IS_DAY_TO_SECOND;
 	data.interval_sign = d.is_negative();
diff --git a/libodbcpp/odbc-param.h b/libodbcpp/odbc-param.h
index 32d3f99..4169a64 100644
--- a/libodbcpp/odbc-param.h
+++ b/libodbcpp/odbc-param.h
@@ -223,7 +223,7 @@ namespace ODBC {
 		{
 			return data.data();
 		}
-		StdStringParam & operator=(const std::string_view & d);
+		StdStringParam & operator=(const std::string_view d);
 		StdStringParam & operator=(const Glib::ustring & d);
 
 	protected:
@@ -261,7 +261,7 @@ namespace ODBC {
 		{
 			return &data;
 		}
-		IntervalParam & operator=(const boost::posix_time::time_duration & d);
+		IntervalParam & operator=(const boost::posix_time::time_duration d);
 
 	protected:
 		SQL_INTERVAL_STRUCT data;
@@ -298,7 +298,7 @@ namespace ODBC {
 		{
 			return &data;
 		}
-		TimeStampParam & operator=(const boost::posix_time::ptime & d);
+		TimeStampParam & operator=(const boost::posix_time::ptime d);
 
 	protected:
 		SQL_TIMESTAMP_STRUCT data;
-- 
cgit v1.2.3