]> Cypherpunks repositories - gostls13.git/commitdiff
compress/lzw: mention relation between litWidth and input bytes
authorJeff R. Allen <jra@nella.org>
Wed, 17 Jun 2015 12:07:13 +0000 (14:07 +0200)
committerNigel Tao <nigeltao@golang.org>
Thu, 18 Jun 2015 22:09:37 +0000 (22:09 +0000)
Add sentences to the docs explaining the limit on input
bytes implicit in the choice of litWidth, and the fact that
compress and decompress litWidth must match.

Fixes #11142.

Change-Id: I20cfb4df35739f7bfeb50b92c78249df3d47942c
Reviewed-on: https://go-review.googlesource.com/11063
Reviewed-by: Nigel Tao <nigeltao@golang.org>
src/compress/lzw/reader.go
src/compress/lzw/writer.go

index 6800e8323bd1951d13501382f4e60ffe19218f31..28e9f7514f7f3d09a153fd6acaf180ea458e6417 100644 (file)
@@ -227,7 +227,8 @@ func (d *decoder) Close() error {
 // It is the caller's responsibility to call Close on the ReadCloser when
 // finished reading.
 // The number of bits to use for literal codes, litWidth, must be in the
-// range [2,8] and is typically 8.
+// range [2,8] and is typically 8. It must equal the litWidth
+// used during compression.
 func NewReader(r io.Reader, order Order, litWidth int) io.ReadCloser {
        d := new(decoder)
        switch order {
index 961b25f94f5fa6d03bcbdd549534548d69486fcb..e9314fc4740bdb7aef0177ea12d89357670db721 100644 (file)
@@ -230,7 +230,7 @@ func (e *encoder) Close() error {
 // It is the caller's responsibility to call Close on the WriteCloser when
 // finished writing.
 // The number of bits to use for literal codes, litWidth, must be in the
-// range [2,8] and is typically 8.
+// range [2,8] and is typically 8. Input bytes must be less than 1<<litWidth.
 func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser {
        var write func(*encoder, uint32) error
        switch order {