From d1b0909894a302540f979d904dd378af1cad620c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 15 Apr 2016 15:11:34 +0200 Subject: BinaryCacheStore::readFile(): Return a shared_ptr to a string This allows readFile() to indicate that a file doesn't exist, and might eliminate some large string copying. --- src/libutil/compression.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libutil/compression.cc') diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc index a3fa0dab73..b047d305cf 100644 --- a/src/libutil/compression.cc +++ b/src/libutil/compression.cc @@ -55,7 +55,7 @@ std::string compressXZ(const std::string & in) } } -std::string decompressXZ(const std::string & in) +ref decompressXZ(const std::string & in) { LzmaStream strm; @@ -66,7 +66,7 @@ std::string decompressXZ(const std::string & in) lzma_action action = LZMA_RUN; uint8_t outbuf[BUFSIZ]; - string res; + ref res = make_ref(); strm().next_in = (uint8_t *) in.c_str(); strm().avail_in = in.size(); strm().next_out = outbuf; @@ -80,7 +80,7 @@ std::string decompressXZ(const std::string & in) lzma_ret ret = lzma_code(&strm(), action); if (strm().avail_out == 0 || ret == LZMA_STREAM_END) { - res.append((char *) outbuf, sizeof(outbuf) - strm().avail_out); + res->append((char *) outbuf, sizeof(outbuf) - strm().avail_out); strm().next_out = outbuf; strm().avail_out = sizeof(outbuf); } -- cgit 1.4.1