Skip to content

Commit

Permalink
Merge pull request NixOS#11843 from xokdvium/dev/move-fixes
Browse files Browse the repository at this point in the history
fix(treewide): clean up move semantics
  • Loading branch information
Mic92 authored Nov 9, 2024
2 parents cdcf9bd + 0347bca commit aa9c0bc
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/libcmd/installable-flake.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct ExtraPathInfoFlake : ExtraPathInfoValue
Flake flake;

ExtraPathInfoFlake(Value && v, Flake && f)
: ExtraPathInfoValue(std::move(v)), flake(f)
: ExtraPathInfoValue(std::move(v)), flake(std::move(f))
{ }
};

Expand Down
2 changes: 1 addition & 1 deletion src/libcmd/installable-value.hh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct ExtraPathInfoValue : ExtraPathInfo
Value value;

ExtraPathInfoValue(Value && v)
: value(v)
: value(std::move(v))
{ }

virtual ~ExtraPathInfoValue() = default;
Expand Down
4 changes: 4 additions & 0 deletions src/libstore/derivations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ struct BasicDerivation
std::string name;

BasicDerivation() = default;
BasicDerivation(BasicDerivation &&) = default;
BasicDerivation(const BasicDerivation &) = default;
BasicDerivation& operator=(BasicDerivation &&) = default;
BasicDerivation& operator=(const BasicDerivation &) = default;
virtual ~BasicDerivation() { };

bool isBuiltin() const;
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/filetransfer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ struct curlFileTransfer : public FileTransfer
template<class T>
void fail(T && e)
{
failEx(std::make_exception_ptr(std::move(e)));
failEx(std::make_exception_ptr(std::forward<T>(e)));
}

LambdaSink finalSink;
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/machines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Machine::Machine(
systemTypes(systemTypes),
sshKey(sshKey),
maxJobs(maxJobs),
speedFactor(speedFactor == 0.0f ? 1.0f : std::move(speedFactor)),
speedFactor(speedFactor == 0.0f ? 1.0f : speedFactor),
supportedFeatures(supportedFeatures),
mandatoryFeatures(mandatoryFeatures),
sshPublicHostKey(sshPublicHostKey)
Expand Down
9 changes: 5 additions & 4 deletions src/libstore/path-info.hh
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,18 @@ struct ValidPathInfo : UnkeyedValidPathInfo {
*/
Strings shortRefs() const;

ValidPathInfo(const ValidPathInfo & other) = default;

ValidPathInfo(StorePath && path, UnkeyedValidPathInfo info) : UnkeyedValidPathInfo(info), path(std::move(path)) { };
ValidPathInfo(const StorePath & path, UnkeyedValidPathInfo info) : UnkeyedValidPathInfo(info), path(path) { };

ValidPathInfo(const Store & store,
std::string_view name, ContentAddressWithReferences && ca, Hash narHash);

virtual ~ValidPathInfo() { }
};

static_assert(std::is_move_assignable_v<ValidPathInfo>);
static_assert(std::is_copy_assignable_v<ValidPathInfo>);
static_assert(std::is_copy_constructible_v<ValidPathInfo>);
static_assert(std::is_move_constructible_v<ValidPathInfo>);

using ValidPathInfos = std::map<StorePath, ValidPathInfo>;

}
2 changes: 1 addition & 1 deletion src/libutil/executable-path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ExecutablePath ExecutablePath::parse(const OsString & path)
std::make_move_iterator(strings.begin()),
std::make_move_iterator(strings.end()),
std::back_inserter(ret),
[](auto && str) {
[](OsString && str) {
return fs::path{
str.empty()
// "A zero-length prefix is a legacy feature that
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/position.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Pos::Pos(const Pos * other)
}
line = other->line;
column = other->column;
origin = std::move(other->origin);
origin = other->origin;
}

Pos::operator std::shared_ptr<Pos>() const
Expand Down
7 changes: 0 additions & 7 deletions src/libutil/ref.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ private:
std::shared_ptr<T> p;

public:

ref(const ref<T> & r)
: p(r.p)
{ }

explicit ref(const std::shared_ptr<T> & p)
: p(p)
{
Expand Down Expand Up @@ -75,8 +70,6 @@ public:
return ref<T2>((std::shared_ptr<T2>) p);
}

ref<T> & operator=(ref<T> const & rhs) = default;

bool operator == (const ref<T> & other) const
{
return p == other.p;
Expand Down

0 comments on commit aa9c0bc

Please sign in to comment.