From df23f3ed2242464edf53b6842a49c61d36985aea Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 1 Apr 2022 20:50:31 +0200 Subject: [PATCH] micro opt lz4/zstd decompress: keep memoryview a bit longer, fixes #3412 if LZ4/ZSTD.decompress gets called with a memoryview idata, keep it until after the super().decompress(idata) call, so we save one copy operation just to remove the 2 bytes long compression type header. --- src/borg/compress.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/borg/compress.pyx b/src/borg/compress.pyx index 32ecb0b53..493b4a53a 100644 --- a/src/borg/compress.pyx +++ b/src/borg/compress.pyx @@ -202,9 +202,9 @@ class LZ4(DecidingCompressor): return NONE_COMPRESSOR, None def decompress(self, idata): + idata = super().decompress(idata) if not isinstance(idata, bytes): idata = bytes(idata) # code below does not work with memoryview - idata = super().decompress(idata) cdef int isize = len(idata) cdef int osize cdef int rsize @@ -304,9 +304,9 @@ class ZSTD(DecidingCompressor): return NONE_COMPRESSOR, None def decompress(self, idata): + idata = super().decompress(idata) if not isinstance(idata, bytes): idata = bytes(idata) # code below does not work with memoryview - idata = super().decompress(idata) cdef int isize = len(idata) cdef unsigned long long osize cdef unsigned long long rsize