Skip to content

Commit 2a5745d

Browse files
jeffallennigeltao
authored andcommitted
compress/lzw: mention relation between litWidth and input bytes
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>
1 parent 90a1996 commit 2a5745d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/compress/lzw/reader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ func (d *decoder) Close() error {
227227
// It is the caller's responsibility to call Close on the ReadCloser when
228228
// finished reading.
229229
// The number of bits to use for literal codes, litWidth, must be in the
230-
// range [2,8] and is typically 8.
230+
// range [2,8] and is typically 8. It must equal the litWidth
231+
// used during compression.
231232
func NewReader(r io.Reader, order Order, litWidth int) io.ReadCloser {
232233
d := new(decoder)
233234
switch order {

src/compress/lzw/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (e *encoder) Close() error {
230230
// It is the caller's responsibility to call Close on the WriteCloser when
231231
// finished writing.
232232
// The number of bits to use for literal codes, litWidth, must be in the
233-
// range [2,8] and is typically 8.
233+
// range [2,8] and is typically 8. Input bytes must be less than 1<<litWidth.
234234
func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser {
235235
var write func(*encoder, uint32) error
236236
switch order {

0 commit comments

Comments
 (0)