ZStandard: Optimize passing the memory
In the case of decompression, we are using the same chunk of memory twice. The first is to obtain the size of decompressed data, and the second is to decompress it. In the current code, we are copying the chunk of memory twice. The memory doesn't change between the calls, so there is no point in copying it over and over. Let's synchronize memory only during first call.pull/112/head
parent
cef861a0f2
commit
dc43384516
|
@ -80,7 +80,7 @@ absl::Status DecompressInMemory(ZstdApi& api, std::ifstream& in_stream,
|
|||
|
||||
SAPI_ASSIGN_OR_RETURN(
|
||||
size_t desize, api.ZSTD_decompress(outbuf.PtrAfter(), size,
|
||||
inbuf.PtrBefore(), inbuf.GetSize()));
|
||||
inbuf.PtrNone(), inbuf.GetSize()));
|
||||
SAPI_ASSIGN_OR_RETURN(iserr, api.ZSTD_isError(desize));
|
||||
if (iserr) {
|
||||
return absl::UnavailableError("Unable to decompress file");
|
||||
|
|
Loading…
Reference in New Issue