ios – Why the size of InputFilter is just not equal to the paging measurement

0
107


I am studying Apple’s Speed up Framework just lately, and I attempted to make use of InputFilter to decompress a compressed information. The demo code is as follows

    func decompressUsingInputFilter(_ compressedData: Knowledge) {        
        let pageSize = 128
        var decompressedData = Knowledge()
        var decompressIndex = 0
        let decompressBufferSize = compressedData.depend
        let inputFilter = strive! InputFilter(.decompress, utilizing: .lzfse) { (size: Int) -> Knowledge? in
            print("size=(size)")
            let rangeLength = min(size, decompressBufferSize - decompressIndex)
            let subdata = compressedData.subdata(in: decompressIndex ..< decompressIndex + rangeLength)
            decompressIndex += rangeLength
            return subdata
        }
        whereas let web page = strive! inputFilter.readData(ofLength: pageSize) {
            decompressedData.append(web page)
        }
        let decompressedString = String(information: decompressedData, encoding: .utf8)!
        print(decompressedString)
    }

I hope that InputFilter will decompress in pages of 128 bytes, however after I debugged it, I discovered that the size handed into the closure of InputFilter was 65536, which appears to be inconsistent with expectations. I wish to know the place the issue is.

demo code