flush writes as much full bytes as possible to the underlying writer
()
| 19 | |
| 20 | // flush writes as much full bytes as possible to the underlying writer |
| 21 | func (w *Writer) flush() { |
| 22 | if w.err != nil { |
| 23 | w.nbits = 0 |
| 24 | return |
| 25 | } |
| 26 | |
| 27 | var buf [16]byte |
| 28 | n := 0 |
| 29 | for w.nbits > 8 { |
| 30 | buf[n] = byte(w.bits) |
| 31 | w.bits >>= 8 |
| 32 | w.nbits -= 8 |
| 33 | n++ |
| 34 | } |
| 35 | |
| 36 | _, w.err = w.w.Write(buf[0:n]) |
| 37 | } |
| 38 | |
| 39 | // flushAll writes all the remaining half bytes |
| 40 | func (w *Writer) flushAll() { |