Skip to content

Commit

Permalink
compress/lzw: mention relation between litWidth and input bytes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jeffallen authored and nigeltao committed Jun 18, 2015
1 parent 90a1996 commit 2a5745d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/compress/lzw/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/compress/lzw/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2a5745d

Please sign in to comment.