mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Use a struct not std::pair
for SearchPathElem
I got very confused trying to keep all the `first` and `second` straight reading the code, *especially* as there is also another `(boolean, string)` pair type also being used. Named fields is much better. There are other cleanups that we can do (for example, the existing TODO), but we can do them later. Doing them now would just make this harder to review.
This commit is contained in:
parent
fd4f03b8fd
commit
484290a9e0
3 changed files with 30 additions and 20 deletions
|
@ -1656,7 +1656,10 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value * * args, V
|
|||
}));
|
||||
}
|
||||
|
||||
searchPath.emplace_back(prefix, path);
|
||||
searchPath.emplace_back(SearchPathElem {
|
||||
.prefix = prefix,
|
||||
.path = path,
|
||||
});
|
||||
}
|
||||
|
||||
auto path = state.forceStringNoCtx(*args[1], pos, "while evaluating the second argument passed to builtins.findFile");
|
||||
|
@ -4129,8 +4132,8 @@ void EvalState::createBaseEnv()
|
|||
int n = 0;
|
||||
for (auto & i : searchPath) {
|
||||
auto attrs = buildBindings(2);
|
||||
attrs.alloc("path").mkString(i.second);
|
||||
attrs.alloc("prefix").mkString(i.first);
|
||||
attrs.alloc("path").mkString(i.path);
|
||||
attrs.alloc("prefix").mkString(i.prefix);
|
||||
(v.listElems()[n++] = allocValue())->mkAttrs(attrs);
|
||||
}
|
||||
addConstant("__nixPath", v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue