(off uint32)
| 121 | } |
| 122 | |
| 123 | func (r *RLE) End(off uint32) []uint32 { |
| 124 | if r.prediction == r.last { |
| 125 | // all nones |
| 126 | r.emit(off) |
| 127 | } else if r.prediction == off { |
| 128 | if len(r.runs) == 1 && r.runs[0] == 0 { |
| 129 | // all values |
| 130 | return nil |
| 131 | } |
| 132 | // write the last run of values |
| 133 | r.emit(off - r.last) |
| 134 | } else { |
| 135 | // write the last run of values and the last run of nones |
| 136 | r.Touch(off) |
| 137 | } |
| 138 | return r.runs |
| 139 | } |
| 140 | |
| 141 | func (r *RLE) emit(run uint32) { |
| 142 | r.runs = append(r.runs, run) |