aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-06-23 12:01:10 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-06-23 12:01:10 -0400
commit484290a9e05ea840f9bc6ba3cc98d64ccffe202b (patch)
treeed55ba1ed4f7e1301dfece37110a467e549015b0 /src/libexpr/primops.cc
parentfd4f03b8fdcb0f33552730c786139019e29f5dbe (diff)
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.
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 5b2f7e8b7..9dd7bae02 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -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);