mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 23:12:44 +01:00
Merge pull request #14323 from NixOS/skip-nar-parse
addToStore(): Don't parse the NAR * StringSource: Implement skip() This is slightly faster than doing a read() into a buffer just to discard the data. * LocalStore::addToStore(): Skip unnecessary NARs rather than parsing them Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
0a74b4905c
commit
d6f1e2de21
3 changed files with 14 additions and 4 deletions
|
|
@ -255,6 +255,8 @@ struct StringSource : Source
|
|||
}
|
||||
|
||||
size_t read(char * data, size_t len) override;
|
||||
|
||||
void skip(size_t len) override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -242,6 +242,16 @@ size_t StringSource::read(char * data, size_t len)
|
|||
return n;
|
||||
}
|
||||
|
||||
void StringSource::skip(size_t len)
|
||||
{
|
||||
const size_t remain = s.size() - pos;
|
||||
if (len > remain) {
|
||||
pos = s.size();
|
||||
throw EndOfFile("end of string reached");
|
||||
}
|
||||
pos += len;
|
||||
}
|
||||
|
||||
std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
|
||||
{
|
||||
struct SourceToSink : FinishSink
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue