summaryrefslogtreecommitdiff
path: root/libgo/go/compress/lzw/reader.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/compress/lzw/reader.go')
-rw-r--r--libgo/go/compress/lzw/reader.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/libgo/go/compress/lzw/reader.go b/libgo/go/compress/lzw/reader.go
index 1be52d55e4f..f08021190c2 100644
--- a/libgo/go/compress/lzw/reader.go
+++ b/libgo/go/compress/lzw/reader.go
@@ -63,8 +63,7 @@ type decoder struct {
//
// last is the most recently seen code, or decoderInvalidCode.
//
- // An invariant is that
- // (hi < overflow) || (hi == overflow && last == decoderInvalidCode)
+ // An invariant is that hi < overflow.
clear, eof, hi, overflow, last uint16
// Each code c in [lo, hi] expands to two or more bytes. For c != hi:
@@ -200,15 +199,18 @@ loop:
}
d.last, d.hi = code, d.hi+1
if d.hi >= d.overflow {
+ if d.hi > d.overflow {
+ panic("unreachable")
+ }
if d.width == maxWidth {
d.last = decoderInvalidCode
// Undo the d.hi++ a few lines above, so that (1) we maintain
- // the invariant that d.hi <= d.overflow, and (2) d.hi does not
+ // the invariant that d.hi < d.overflow, and (2) d.hi does not
// eventually overflow a uint16.
d.hi--
} else {
d.width++
- d.overflow <<= 1
+ d.overflow = 1 << d.width
}
}
if d.o >= flushBuffer {