1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 16:51:15 +02:00

Eliminate some large string copying

This commit is contained in:
Eelco Dolstra 2016-03-04 16:49:56 +01:00
parent ce113c32d2
commit 42bc395b63
5 changed files with 25 additions and 23 deletions

View file

@ -288,11 +288,11 @@ template PathSet readStrings(Source & source);
void StringSink::operator () (const unsigned char * data, size_t len)
{
static bool warned = false;
if (!warned && s.size() > threshold) {
if (!warned && s->size() > threshold) {
warnLargeDump();
warned = true;
}
s.append((const char *) data, len);
s->append((const char *) data, len);
}

View file

@ -110,7 +110,9 @@ private:
/* A sink that writes data to a string. */
struct StringSink : Sink
{
string s;
ref<std::string> s;
StringSink() : s(make_ref<std::string>()) { };
StringSink(ref<std::string> s) : s(s) { };
void operator () (const unsigned char * data, size_t len) override;
};