Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Buffer/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ class Buffer {
Buffer& operator = (const Buffer& buf) = delete;
Buffer(Buffer &&other) noexcept
{
/* Call move assignment operator. */
*this = std::forward<Buffer>(other);
*this = std::move(other);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we could rewrite all the move constructors from this commit in one line now, like:

Buffer(Buffer &&other) noexcept { *this = std::move(other); }

}
Buffer &operator=(Buffer &&other) noexcept
{
Expand Down
13 changes: 7 additions & 6 deletions src/Client/Connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <sys/uio.h> //iovec
#include <string>
#include <string_view>
#include <unordered_map> //futures

/** rid == request id */
Expand Down Expand Up @@ -175,7 +176,7 @@ class Connection
size_t getFutureCount() const;

template <class T>
rid_t call(const std::string &func, const T &args);
rid_t call(std::string_view func, const T &args);
rid_t ping();

/**
Expand All @@ -185,7 +186,7 @@ class Connection
* @retval request id
*/
template <class T>
rid_t execute(const std::string& statement, const T& parameters);
rid_t execute(std::string_view statement, const T& parameters);

/**
* Execute the SQL statement contained in the 'statement' parameter.
Expand All @@ -203,7 +204,7 @@ class Connection
* @param statement statement, which should conform to the rules for SQL grammar
* @retval request id
*/
rid_t prepare(const std::string& statement);
rid_t prepare(std::string_view statement);

void setError(const std::string &msg, int errno_ = 0);
bool hasError() const;
Expand Down Expand Up @@ -606,7 +607,7 @@ decodeGreeting(Connection<BUFFER, NetProvider> &conn)
template<class BUFFER, class NetProvider>
template <class T>
rid_t
Connection<BUFFER, NetProvider>::execute(const std::string& statement, const T& parameters)
Connection<BUFFER, NetProvider>::execute(std::string_view statement, const T& parameters)
{
impl->enc.encodeExecute(statement, parameters);
impl->connector.readyToSend(*this);
Expand All @@ -625,7 +626,7 @@ Connection<BUFFER, NetProvider>::execute(unsigned int stmt_id, const T& paramete

template<class BUFFER, class NetProvider>
rid_t
Connection<BUFFER, NetProvider>::prepare(const std::string& statement)
Connection<BUFFER, NetProvider>::prepare(std::string_view statement)
{
impl->enc.encodePrepare(statement);
impl->connector.readyToSend(*this);
Expand All @@ -635,7 +636,7 @@ Connection<BUFFER, NetProvider>::prepare(const std::string& statement)
template<class BUFFER, class NetProvider>
template <class T>
rid_t
Connection<BUFFER, NetProvider>::call(const std::string &func, const T &args)
Connection<BUFFER, NetProvider>::call(std::string_view func, const T &args)
{
impl->enc.encodeCall(func, args);
impl->connector.readyToSend(*this);
Expand Down
13 changes: 7 additions & 6 deletions src/Client/RequestEncoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <any>
#include <cstdint>
#include <map>
#include <string_view>

#include "IprotoConstants.hpp"
#include "ResponseReader.hpp"
Expand Down Expand Up @@ -85,12 +86,12 @@ class RequestEncoder {
uint32_t limit = UINT32_MAX, uint32_t offset = 0,
IteratorType iterator = EQ);
template <class T>
size_t encodeExecute(const std::string& statement, const T& parameters);
size_t encodeExecute(std::string_view statement, const T& parameters);
template <class T>
size_t encodeExecute(unsigned int stmt_id, const T& parameters);
size_t encodePrepare(const std::string& statement);
size_t encodePrepare(std::string_view statement);
template <class T>
size_t encodeCall(const std::string &func, const T &args);
size_t encodeCall(std::string_view func, const T &args);
size_t encodeAuth(std::string_view user, std::string_view passwd,
const Greeting &greet);
void reencodeAuth(std::string_view user, std::string_view passwd,
Expand Down Expand Up @@ -256,7 +257,7 @@ RequestEncoder<BUFFER>::encodeSelect(const T &key,
template<class BUFFER>
template <class T>
size_t
RequestEncoder<BUFFER>::encodeExecute(const std::string& statement, const T& parameters)
RequestEncoder<BUFFER>::encodeExecute(std::string_view statement, const T& parameters)
{
iterator_t<BUFFER> request_start = m_Buf.end();
m_Buf.write('\xce');
Expand Down Expand Up @@ -293,7 +294,7 @@ RequestEncoder<BUFFER>::encodeExecute(unsigned int stmt_id, const T& parameters)

template<class BUFFER>
size_t
RequestEncoder<BUFFER>::encodePrepare(const std::string& statement)
RequestEncoder<BUFFER>::encodePrepare(std::string_view statement)
{
iterator_t<BUFFER> request_start = m_Buf.end();
m_Buf.write('\xce');
Expand All @@ -310,7 +311,7 @@ RequestEncoder<BUFFER>::encodePrepare(const std::string& statement)
template<class BUFFER>
template <class T>
size_t
RequestEncoder<BUFFER>::encodeCall(const std::string &func, const T &args)
RequestEncoder<BUFFER>::encodeCall(std::string_view func, const T &args)
{
iterator_t<BUFFER> request_start = m_Buf.end();
m_Buf.write('\xce');
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Logger {
std::stringstream strm;
strm << log_lvl << ": ";
(strm << ... << std::forward<ARGS>(args)) << '\n';
std::string str = strm.str();
std::string str = std::move(strm).str();
ssize_t rc = write(fd, std::data(str), std::size(str));
(void)rc;
}
Expand Down
8 changes: 3 additions & 5 deletions src/Utils/Mempool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class MempoolStats {
MempoolStats() = default;
MempoolStats(MempoolStats &&other) noexcept
{
/* Call move assignment operator. */
*this = std::forward<MempoolStats>(other);
*this = std::move<MempoolStats>(other);
}
MempoolStats &operator=(MempoolStats &&other) noexcept
{
Expand Down Expand Up @@ -136,15 +135,14 @@ class MempoolInstance : public MempoolStats<ENABLE_STATS> {
MempoolInstance &operator=(const MempoolInstance &other) = delete;
MempoolInstance(MempoolInstance &&other) noexcept
{
/* Call move assignment operator. */
*this = std::forward<MempoolInstance>(other);
*this = std::move(other);
}
MempoolInstance &operator=(MempoolInstance &&other) noexcept
{
if (this == &other)
return *this;
/* Move base class. */
MempoolStats<ENABLE_STATS>::operator=(std::forward<MempoolInstance>(other));
MempoolStats<ENABLE_STATS>::operator=(std::move(other));
std::swap(m_SlabList, other.m_SlabList);
std::swap(m_FreeList, other.m_FreeList);
std::swap(m_SlabDataBeg, other.m_SlabDataBeg);
Expand Down
Loading