mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 07:22:43 +01:00
Cleanup: Use C++23 "explicit this" for recursive lambdas
Try to pass by reference where possible. Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
This commit is contained in:
parent
3b2186e1c8
commit
1507843f6c
15 changed files with 60 additions and 112 deletions
|
|
@ -47,12 +47,12 @@ void SourceAccessor::dumpPath(const CanonPath & path, Sink & sink, PathFilter &
|
|||
writePadding(*size, sink);
|
||||
};
|
||||
|
||||
std::function<void(const CanonPath & path)> dump;
|
||||
sink << narVersionMagic1;
|
||||
|
||||
dump = [&](const CanonPath & path) {
|
||||
[&, &this_(*this)](this const auto & dump, const CanonPath & path) -> void {
|
||||
checkInterrupt();
|
||||
|
||||
auto st = lstat(path);
|
||||
auto st = this_.lstat(path);
|
||||
|
||||
sink << "(";
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ void SourceAccessor::dumpPath(const CanonPath & path, Sink & sink, PathFilter &
|
|||
/* If we're on a case-insensitive system like macOS, undo
|
||||
the case hack applied by restorePath(). */
|
||||
StringMap unhacked;
|
||||
for (auto & i : readDirectory(path))
|
||||
for (auto & i : this_.readDirectory(path))
|
||||
if (archiveSettings.useCaseHack) {
|
||||
std::string name(i.first);
|
||||
size_t pos = i.first.find(caseHackSuffix);
|
||||
|
|
@ -92,16 +92,13 @@ void SourceAccessor::dumpPath(const CanonPath & path, Sink & sink, PathFilter &
|
|||
}
|
||||
|
||||
else if (st.type == tSymlink)
|
||||
sink << "type" << "symlink" << "target" << readLink(path);
|
||||
sink << "type" << "symlink" << "target" << this_.readLink(path);
|
||||
|
||||
else
|
||||
throw Error("file '%s' has an unsupported type", path);
|
||||
|
||||
sink << ")";
|
||||
};
|
||||
|
||||
sink << narVersionMagic1;
|
||||
dump(path);
|
||||
}(path);
|
||||
}
|
||||
|
||||
time_t dumpPathAndGetMtime(const Path & path, Sink & sink, PathFilter & filter)
|
||||
|
|
|
|||
|
|
@ -24,11 +24,9 @@ void computeClosure(const set<T> startElts, set<T> & res, GetEdgesAsync<T> getEd
|
|||
|
||||
Sync<State> state_(State{0, res, 0});
|
||||
|
||||
std::function<void(const T &)> enqueue;
|
||||
|
||||
std::condition_variable done;
|
||||
|
||||
enqueue = [&](const T & current) -> void {
|
||||
auto enqueue = [&](this auto & enqueue, const T & current) -> void {
|
||||
{
|
||||
auto state(state_.lock());
|
||||
if (state->exc)
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@ std::vector<T> topoSort(
|
|||
std::vector<T> sorted;
|
||||
decltype(items) visited, parents;
|
||||
|
||||
std::function<void(const T & path, const T * parent)> dfsVisit;
|
||||
|
||||
dfsVisit = [&](const T & path, const T * parent) {
|
||||
auto dfsVisit = [&](this auto & dfsVisit, const T & path, const T * parent) {
|
||||
if (parents.count(path))
|
||||
throw makeCycleError(path, *parent);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue