Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: moving instead of copying std::string argument #344

Merged
merged 1 commit into from
Aug 3, 2023
Merged
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
8 changes: 4 additions & 4 deletions include/sdbus-c++/ConvenienceApiClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace sdbus {
class MethodRegistrator
{
public:
MethodRegistrator(IObject& object, const std::string& methodName);
MethodRegistrator(IObject& object, std::string methodName);
MethodRegistrator(MethodRegistrator&& other) = default;
~MethodRegistrator() noexcept(false);

Expand All @@ -67,7 +67,7 @@ namespace sdbus {

private:
IObject& object_;
const std::string& methodName_;
std::string methodName_;
std::string interfaceName_;
std::string inputSignature_;
std::vector<std::string> inputParamNames_;
Expand All @@ -81,7 +81,7 @@ namespace sdbus {
class SignalRegistrator
{
public:
SignalRegistrator(IObject& object, const std::string& signalName);
SignalRegistrator(IObject& object, std::string signalName);
SignalRegistrator(SignalRegistrator&& other) = default;
~SignalRegistrator() noexcept(false);

Expand All @@ -93,7 +93,7 @@ namespace sdbus {

private:
IObject& object_;
const std::string& signalName_;
std::string signalName_;
std::string interfaceName_;
std::string signalSignature_;
std::vector<std::string> paramNames_;
Expand Down
14 changes: 7 additions & 7 deletions include/sdbus-c++/ConvenienceApiClasses.inl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ namespace sdbus {
/*** MethodRegistrator ***/
/*** ----------------- ***/

inline MethodRegistrator::MethodRegistrator(IObject& object, const std::string& methodName)
inline MethodRegistrator::MethodRegistrator(IObject& object, std::string methodName)
: object_(object)
, methodName_(methodName)
, methodName_(std::move(methodName))
, exceptions_(std::uncaught_exceptions())
{
}
Expand All @@ -73,9 +73,9 @@ namespace sdbus {
object_.registerMethod( interfaceName_
, std::move(methodName_)
, std::move(inputSignature_)
, std::move(inputParamNames_)
, inputParamNames_
, std::move(outputSignature_)
, std::move(outputParamNames_)
, outputParamNames_
, std::move(methodCallback_)
, std::move(flags_));
}
Expand Down Expand Up @@ -177,9 +177,9 @@ namespace sdbus {
/*** SignalRegistrator ***/
/*** ----------------- ***/

inline SignalRegistrator::SignalRegistrator(IObject& object, const std::string& signalName)
inline SignalRegistrator::SignalRegistrator(IObject& object, std::string signalName)
: object_(object)
, signalName_(signalName)
, signalName_(std::move(signalName))
, exceptions_(std::uncaught_exceptions())
{
}
Expand All @@ -204,7 +204,7 @@ namespace sdbus {
object_.registerSignal( interfaceName_
, std::move(signalName_)
, std::move(signalSignature_)
, std::move(paramNames_)
, paramNames_
, std::move(flags_) );
}

Expand Down