diff options
| author | 2025-11-22 08:00:00 +0800 | |
|---|---|---|
| committer | 2025-11-22 08:00:00 +0800 | |
| commit | 9b453a7cca6bb258a8ca939dc9696fabd77b1b7c (patch) | |
| tree | 27f28df16a5f00f79021f9bd4d6d540435c9d2f8 /internal/zlibx/decompress.go | |
| parent | flatex: Remove the stale readByte(s) wrappers and just directly index the buffer (diff) | |
| signature | No signature | |
zlib, flatex: Remove code related to dicts
Git never uses them
Diffstat (limited to 'internal/zlibx/decompress.go')
| -rw-r--r-- | internal/zlibx/decompress.go | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/internal/zlibx/decompress.go b/internal/zlibx/decompress.go index 68a92587..df4a34be 100644 --- a/internal/zlibx/decompress.go +++ b/internal/zlibx/decompress.go @@ -9,28 +9,11 @@ import ( "git.sr.ht/~runxiyu/furgit/internal/flatex" ) -// Decompress inflates the provided zlib wrapped stream and returns the -// uncompressed data inside a pooled bufpool.Buffer. func Decompress(src []byte) (*bufpool.Buffer, error) { return DecompressSized(src, 0) } -// DecompressSized inflates the provided zlib stream, using sizeHint to -// preallocate the output buffer when known (e.g. packfile entries). func DecompressSized(src []byte, sizeHint int) (*bufpool.Buffer, error) { - return DecompressDictSized(src, nil, sizeHint) -} - -// DecompressDict is like Decompress but accepts a preset dictionary. The -// dictionary must match the checksum embedded in the stream if the dictionary -// flag is present. -func DecompressDict(src []byte, dict []byte) (*bufpool.Buffer, error) { - return DecompressDictSized(src, dict, 0) -} - -// DecompressDictSized is like DecompressDict but allows providing an expected -// uncompressed size to avoid buffer growth copies. -func DecompressDictSized(src []byte, dict []byte, sizeHint int) (*bufpool.Buffer, error) { if len(src) < 6 { return nil, io.ErrUnexpectedEOF } @@ -42,19 +25,8 @@ func DecompressDictSized(src []byte, dict []byte, sizeHint int) (*bufpool.Buffer } offset := 2 - haveDict := flg&0x20 != 0 - if haveDict { - if len(src) < offset+4 { - return nil, io.ErrUnexpectedEOF - } - if dict == nil { - return nil, ErrDictionary - } - checksum := binary.BigEndian.Uint32(src[offset : offset+4]) - if checksum != adler32.Checksum(dict) { - return nil, ErrDictionary - } - offset += 4 + if flg&0x20 != 0 { + return nil, ErrHeader } if len(src[offset:]) < 4 { @@ -62,7 +34,7 @@ func DecompressDictSized(src []byte, dict []byte, sizeHint int) (*bufpool.Buffer } deflateData := src[offset:] - out, consumed, err := flatex.DecompressDictSized(deflateData, dict, sizeHint) + out, consumed, err := flatex.DecompressSized(deflateData, sizeHint) if err != nil { return nil, err } |
