浏览代码

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.
Thomas Waldmann 3 年之前
父节点
当前提交
df23f3ed22
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/borg/compress.pyx

+ 2 - 2
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