mirror of
https://github.com/NixOS/nix.git
synced 2025-11-20 17:29:36 +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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue