mirror of
https://github.com/NixOS/nix.git
synced 2025-12-14 21:11:04 +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
|
|
@ -92,7 +92,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
|
|||
|
||||
std::istringstream tomlStream(std::string{toml});
|
||||
|
||||
auto visit = [&](auto & self, Value & v, toml::value t) -> void {
|
||||
auto visit = [&](this auto & self, Value & v, toml::value t) -> void {
|
||||
switch (t.type()) {
|
||||
case toml::value_t::table: {
|
||||
auto table = toml::get<toml::table>(t);
|
||||
|
|
@ -100,7 +100,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
|
|||
|
||||
for (auto & elem : table) {
|
||||
forceNoNullByte(elem.first);
|
||||
self(self, attrs.alloc(elem.first), elem.second);
|
||||
self(attrs.alloc(elem.first), elem.second);
|
||||
}
|
||||
|
||||
v.mkAttrs(attrs);
|
||||
|
|
@ -110,7 +110,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
|
|||
|
||||
auto list = state.buildList(array.size());
|
||||
for (const auto & [n, v] : enumerate(list))
|
||||
self(self, *(v = state.allocValue()), array[n]);
|
||||
self(*(v = state.allocValue()), array[n]);
|
||||
v.mkList(list);
|
||||
} break;
|
||||
case toml::value_t::boolean:
|
||||
|
|
@ -155,7 +155,6 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
|
|||
|
||||
try {
|
||||
visit(
|
||||
visit,
|
||||
val,
|
||||
toml::parse(
|
||||
tomlStream,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue