diff options
author | eldritch horrors <pennae@lix.systems> | 2024-05-03 22:53:24 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-06-19 10:50:12 +0000 |
commit | 11f4a5bc7eca8a4cca2ae9f3d83b69cd497933f8 (patch) | |
tree | b991157e020697bb4f05ad4629298b183cb5ed61 /src/libstore | |
parent | 67f778670c085615470b67eb3c54885b8c2d482e (diff) |
libutil: return a source from readFile
don't consume a sink, return a source instead. the only reason to not do
this is a very slight reduction in dynamic allocations, but since we are
going to *at least* do disk io that will not be a lot of overhead anyway
Change-Id: Iae2f879ec64c3c3ac1d5310eeb6a85e696d4614a
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/binary-cache-store.cc | 2 | ||||
-rw-r--r-- | src/libstore/build/local-derivation-goal.cc | 4 | ||||
-rw-r--r-- | src/libstore/local-binary-cache-store.cc | 2 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 4 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 2 |
5 files changed, 7 insertions, 7 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 07c722016..d6ded0a24 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -385,7 +385,7 @@ StorePath BinaryCacheStore::addToStore( if (method == FileIngestionMethod::Recursive) { dumpPath(srcPath, sink, filter); } else { - readFile(srcPath, sink); + readFileSource(srcPath)->drainInto(sink); } auto h = sink.finish().first; diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index 7066f5c93..bae821266 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -2486,7 +2486,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs() HashModuloSink caSink { outputHash.hashType, oldHashPart }; std::visit(overloaded { [&](const TextIngestionMethod &) { - readFile(actualPath, caSink); + readFileSource(actualPath)->drainInto(caSink); }, [&](const FileIngestionMethod & m2) { switch (m2) { @@ -2494,7 +2494,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs() dumpPath(actualPath, caSink); break; case FileIngestionMethod::Flat: - readFile(actualPath, caSink); + readFileSource(actualPath)->drainInto(caSink); break; } }, diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc index 5684dcd80..5f6730476 100644 --- a/src/libstore/local-binary-cache-store.cc +++ b/src/libstore/local-binary-cache-store.cc @@ -71,7 +71,7 @@ protected: void getFile(const std::string & path, Sink & sink) override { try { - readFile(binaryCacheDir + "/" + path, sink); + readFileSource(binaryCacheDir + "/" + path)->drainInto(sink); } catch (SysError & e) { if (e.errNo == ENOENT) throw NoSuchBinaryCacheFile("file '%s' does not exist in binary cache", path); diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 5e79630c6..6f441a0a1 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1890,7 +1890,7 @@ ContentAddress LocalStore::hashCAPath( HashModuloSink caSink ( hashType, std::string(pathHash) ); std::visit(overloaded { [&](const TextIngestionMethod &) { - readFile(path, caSink); + readFileSource(path)->drainInto(caSink); }, [&](const FileIngestionMethod & m2) { switch (m2) { @@ -1898,7 +1898,7 @@ ContentAddress LocalStore::hashCAPath( dumpPath(path, caSink); break; case FileIngestionMethod::Flat: - readFile(path, caSink); + readFileSource(path)->drainInto(caSink); break; } }, diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 55083e834..e954acff3 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -279,7 +279,7 @@ StorePath Store::addToStore( if (method == FileIngestionMethod::Recursive) dumpPath(srcPath, sink, filter); else - readFile(srcPath, sink); + readFileSource(srcPath)->drainInto(sink); }); return addToStoreFromDump(*source, name, method, hashAlgo, repair, references); } |