aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-04-16 14:27:54 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-04-16 14:27:54 +0200
commit7b312a8762988ff7a8e0f0890fcd2406cd89c1a3 (patch)
tree4367aff9058e876ff60acb6f54f5ecfe8e8bb83d /src
parente1d73edb10ca38184c85b3124b4c59c6f04a0851 (diff)
Pass stuff by reference
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/primops/flake.cc17
-rw-r--r--src/libexpr/primops/flake.hh7
2 files changed, 13 insertions, 11 deletions
diff --git a/src/libexpr/primops/flake.cc b/src/libexpr/primops/flake.cc
index f65ae09ea..3d11d9ec4 100644
--- a/src/libexpr/primops/flake.cc
+++ b/src/libexpr/primops/flake.cc
@@ -34,7 +34,7 @@ std::shared_ptr<FlakeRegistry> readRegistry(const Path & path)
}
/* Write a registry to a file. */
-void writeRegistry(const FlakeRegistry & registry, Path path)
+void writeRegistry(const FlakeRegistry & registry, const Path & path)
{
nlohmann::json json;
json["version"] = 1;
@@ -99,7 +99,7 @@ LockFile readLockFile(const Path & path)
return lockFile;
}
-nlohmann::json flakeEntryToJson(LockFile::FlakeEntry & entry)
+nlohmann::json flakeEntryToJson(const LockFile::FlakeEntry & entry)
{
nlohmann::json json;
json["uri"] = entry.ref.to_string();
@@ -110,7 +110,7 @@ nlohmann::json flakeEntryToJson(LockFile::FlakeEntry & entry)
return json;
}
-void writeLockFile(LockFile lockFile, Path path)
+void writeLockFile(const LockFile & lockFile, const Path & path)
{
nlohmann::json json;
json["version"] = 1;
@@ -156,7 +156,8 @@ const std::vector<std::shared_ptr<FlakeRegistry>> EvalState::getFlakeRegistries(
}
static FlakeRef lookupFlake(EvalState & state, const FlakeRef & flakeRef,
- std::vector<std::shared_ptr<FlakeRegistry>> registries, std::vector<FlakeRef> pastSearches = {})
+ const std::vector<std::shared_ptr<FlakeRegistry>> & registries,
+ std::vector<FlakeRef> pastSearches = {})
{
for (std::shared_ptr<FlakeRegistry> registry : registries) {
auto i = registry->entries.find(flakeRef);
@@ -362,14 +363,14 @@ Dependencies resolveFlake(EvalState & state, const FlakeRef & topRef, bool impur
return deps;
}
-LockFile::FlakeEntry dependenciesToFlakeEntry(Dependencies & deps)
+LockFile::FlakeEntry dependenciesToFlakeEntry(const Dependencies & deps)
{
LockFile::FlakeEntry entry(deps.flake.ref);
- for (Dependencies & deps : deps.flakeDeps)
+ for (auto & deps : deps.flakeDeps)
entry.flakeEntries.insert_or_assign(deps.flake.id, dependenciesToFlakeEntry(deps));
- for (NonFlake & nonFlake : deps.nonFlakeDeps)
+ for (auto & nonFlake : deps.nonFlakeDeps)
entry.nonFlakeEntries.insert_or_assign(nonFlake.alias, nonFlake.ref);
return entry;
@@ -385,7 +386,7 @@ LockFile getLockFile(EvalState & evalState, FlakeRef & flakeRef)
return lockFile;
}
-void updateLockFile(EvalState & state, Path path)
+void updateLockFile(EvalState & state, const Path & path)
{
// 'path' is the path to the local flake repo.
FlakeRef flakeRef = FlakeRef("file://" + path);
diff --git a/src/libexpr/primops/flake.hh b/src/libexpr/primops/flake.hh
index 73446c908..347dd2077 100644
--- a/src/libexpr/primops/flake.hh
+++ b/src/libexpr/primops/flake.hh
@@ -33,7 +33,7 @@ void makeFlakeValue(EvalState & state, const FlakeRef & flakeRef, bool impureTop
std::shared_ptr<FlakeRegistry> readRegistry(const Path &);
-void writeRegistry(const FlakeRegistry &, Path);
+void writeRegistry(const FlakeRegistry &, const Path &);
struct Flake
{
@@ -75,7 +75,8 @@ struct Dependencies
Dependencies resolveFlake(EvalState &, const FlakeRef &, bool impureTopRef, bool isTopFlake = true);
-FlakeRegistry updateLockFile(EvalState &, Flake &);
+FlakeRegistry updateLockFile(EvalState &, const Flake &);
+
+void updateLockFile(EvalState &, const Path & path);
-void updateLockFile(EvalState &, Path path);
}