mirror of
https://github.com/NixOS/nix
synced 2025-06-29 10:31:15 +02:00
Optimize addToStoreSlow
and remove TeeParseSink
This commit is contained in:
parent
36a1242603
commit
68dfb8c6ae
4 changed files with 65 additions and 54 deletions
|
@ -63,12 +63,29 @@ struct ParseSink
|
|||
virtual void createSymlink(const Path & path, const string & target) { };
|
||||
};
|
||||
|
||||
struct TeeParseSink : ParseSink
|
||||
/* If the NAR archive contains a single file at top-level, then save
|
||||
the contents of the file to `s'. Otherwise barf. */
|
||||
struct RetrieveRegularNARSink : ParseSink
|
||||
{
|
||||
StringSink saved;
|
||||
TeeSource source;
|
||||
bool regular = true;
|
||||
Sink & sink;
|
||||
|
||||
TeeParseSink(Source & source) : source(source, saved) { }
|
||||
RetrieveRegularNARSink(Sink & sink) : sink(sink) { }
|
||||
|
||||
void createDirectory(const Path & path)
|
||||
{
|
||||
regular = false;
|
||||
}
|
||||
|
||||
void receiveContents(unsigned char * data, unsigned int len)
|
||||
{
|
||||
sink(data, len);
|
||||
}
|
||||
|
||||
void createSymlink(const Path & path, const string & target)
|
||||
{
|
||||
regular = false;
|
||||
}
|
||||
};
|
||||
|
||||
void parseDump(ParseSink & sink, Source & source);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue