aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-01-17 22:20:05 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-01-18 11:12:30 +0100
commitd62a9390fcdc0f9e4971e5fab2f667567237b252 (patch)
treecdbf6aef8b15b2ba5f02f7426ec2e5cd1f595e39 /src/nix
parent52ee7ec0028263f04e15c05256ca90fa62a0da66 (diff)
Get rid of std::shared_ptr<std::string> and ref<std::string>
These were needed back in the pre-C++11 era because we didn't have move semantics. But now we do.
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/add-to-store.cc6
-rw-r--r--src/nix/cat.cc2
-rw-r--r--src/nix/ls.cc2
-rw-r--r--src/nix/make-content-addressable.cc8
-rw-r--r--src/nix/profile.cc6
-rw-r--r--src/nix/upgrade-nix.cc2
6 files changed, 13 insertions, 13 deletions
diff --git a/src/nix/add-to-store.cc b/src/nix/add-to-store.cc
index 2ae042789..5168413d2 100644
--- a/src/nix/add-to-store.cc
+++ b/src/nix/add-to-store.cc
@@ -32,7 +32,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
StringSink sink;
dumpPath(path, sink);
- auto narHash = hashString(htSHA256, *sink.s);
+ auto narHash = hashString(htSHA256, sink.s);
Hash hash = narHash;
if (ingestionMethod == FileIngestionMethod::Flat) {
@@ -45,14 +45,14 @@ struct CmdAddToStore : MixDryRun, StoreCommand
store->makeFixedOutputPath(ingestionMethod, hash, *namePart),
narHash,
};
- info.narSize = sink.s->size();
+ info.narSize = sink.s.size();
info.ca = std::optional { FixedOutputHash {
.method = ingestionMethod,
.hash = hash,
} };
if (!dryRun) {
- auto source = StringSource { *sink.s };
+ auto source = StringSource(sink.s);
store->addToStore(info, source);
}
diff --git a/src/nix/cat.cc b/src/nix/cat.cc
index e28ee3c50..6420a0f79 100644
--- a/src/nix/cat.cc
+++ b/src/nix/cat.cc
@@ -78,7 +78,7 @@ struct CmdCatNar : StoreCommand, MixCat
void run(ref<Store> store) override
{
- cat(makeNarAccessor(make_ref<std::string>(readFile(narPath))));
+ cat(makeNarAccessor(readFile(narPath)));
}
};
diff --git a/src/nix/ls.cc b/src/nix/ls.cc
index c1dc9a95b..07554994b 100644
--- a/src/nix/ls.cc
+++ b/src/nix/ls.cc
@@ -157,7 +157,7 @@ struct CmdLsNar : Command, MixLs
void run() override
{
- list(makeNarAccessor(make_ref<std::string>(readFile(narPath))));
+ list(makeNarAccessor(readFile(narPath)));
}
};
diff --git a/src/nix/make-content-addressable.cc b/src/nix/make-content-addressable.cc
index 12f303a10..2e75a3b61 100644
--- a/src/nix/make-content-addressable.cc
+++ b/src/nix/make-content-addressable.cc
@@ -61,10 +61,10 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
}
}
- *sink.s = rewriteStrings(*sink.s, rewrites);
+ sink.s = rewriteStrings(sink.s, rewrites);
HashModuloSink hashModuloSink(htSHA256, oldHashPart);
- hashModuloSink(*sink.s);
+ hashModuloSink(sink.s);
auto narHash = hashModuloSink.finish().first;
@@ -74,7 +74,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
};
info.references = std::move(references);
if (hasSelfReference) info.references.insert(info.path);
- info.narSize = sink.s->size();
+ info.narSize = sink.s.size();
info.ca = FixedOutputHash {
.method = FileIngestionMethod::Recursive,
.hash = info.narHash,
@@ -85,7 +85,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
auto source = sinkToSource([&](Sink & nextSink) {
RewritingSink rsink2(oldHashPart, std::string(info.path.hashPart()), nextSink);
- rsink2(*sink.s);
+ rsink2(sink.s);
rsink2.flush();
});
diff --git a/src/nix/profile.cc b/src/nix/profile.cc
index 96a20f673..9b7c999af 100644
--- a/src/nix/profile.cc
+++ b/src/nix/profile.cc
@@ -157,17 +157,17 @@ struct ProfileManifest
StringSink sink;
dumpPath(tempDir, sink);
- auto narHash = hashString(htSHA256, *sink.s);
+ auto narHash = hashString(htSHA256, sink.s);
ValidPathInfo info {
store->makeFixedOutputPath(FileIngestionMethod::Recursive, narHash, "profile", references),
narHash,
};
info.references = std::move(references);
- info.narSize = sink.s->size();
+ info.narSize = sink.s.size();
info.ca = FixedOutputHash { .method = FileIngestionMethod::Recursive, .hash = info.narHash };
- auto source = StringSource { *sink.s };
+ StringSource source(sink.s);
store->addToStore(info, source);
return std::move(info.path);
diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc
index 9cd567896..17a5a77ee 100644
--- a/src/nix/upgrade-nix.cc
+++ b/src/nix/upgrade-nix.cc
@@ -140,7 +140,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
auto state = std::make_unique<EvalState>(Strings(), store);
auto v = state->allocValue();
- state->eval(state->parseExprFromString(*res.data, "/no-such-path"), *v);
+ state->eval(state->parseExprFromString(res.data, "/no-such-path"), *v);
Bindings & bindings(*state->allocBindings(0));
auto v2 = findAlongAttrPath(*state, settings.thisSystem, bindings, *v).first;