Diff

Differences From Artifact [2d2f3f4577]:

To Artifact [bc261fa076]:


    69     69   			length += 2
    70     70   			continue
    71     71   		}
    72     72   
    73     73   		value >>= 1
    74     74   		length++
    75     75   	}
    76         -	result += f[length] - 1
    77         -	return
           76  +	return result + f[length] - 1, length + 1
    78     77   }
    79     78   
    80     79   func Writer(target io.Writer) io.Writer {
    81     80   	var enc encoder
    82         -	enc.Numbers = New(16)
           81  +	enc.Numbers = New(14)
    83     82   	enc.target = target
    84     83   	enc.buffer = enc.backing[:0:len(enc.backing)]
    85     84   	return &enc
    86     85   }
    87     86   
    88     87   type encoder struct {
    89     88   	Numbers
    90     89   	target    io.Writer
    91         -	backing   [3]byte // TODO - verify that this can be reduced to 2 bytes
           90  +	backing   [2]byte
    92     91   	buffer    []byte
    93     92   	remaining byte
    94     93   	length    byte
    95     94   }
    96     95   
    97     96   func (e *encoder) Write(input []byte) (int, error) {
    98     97   	var (
................................................................................
   173    172   // 	Numbers
   174    173   // 	source io.Reader
   175    174   // 	buffer uint64
   176    175   // 	at     byte
   177    176   // }
   178    177   
   179    178   // func (d *decoder) Read(output []byte) (int, error) {
   180         -// 	return 0, nil
          179  +// 	var (
          180  +// 		total int
          181  +// 		err   error
          182  +// 	)
          183  +
          184  +// 	// While we have suitable buffered data and enough output space
          185  +// 	for (len(output) > 0) && ((d.buffer & (d.buffer >> 1)) > 0) {
          186  +// 		val, len := d.Decode(d.buffer)
          187  +
          188  +// 		// Store the decoded byte
          189  +// 		output[0] = byte(val)
          190  +
          191  +// 		// Advance the internal and output buffers
          192  +// 		output = output[1:]
          193  +// 		d.buffer >>= len
          194  +
          195  +// 		// TODO - decrease d.at as well ?
          196  +
          197  +// 		total++
          198  +// 	}
          199  +
          200  +// 	// Termination condition
          201  +// 	if len(output) == 0 {
          202  +// 		return total, nil
          203  +// 	}
          204  +
          205  +// 	// count, err := d.source.Read(output)
          206  +
          207  +// 	return total, err
   181    208   // }