refactor: eliminate ReadBytes() function that is only called once

This commit is contained in:
Bryan Boreham
2019-09-17 10:55:44 +00:00
parent 2bbd4a3f0d
commit 5ffb563051
+1 -6
View File
@@ -102,7 +102,7 @@ func (rep *Report) ReadBinary(ctx context.Context, r io.Reader, gzipped bool, ms
if err != nil {
return err
}
if err := rep.ReadBytes(buf.Bytes(), codecHandle(msgpack)); err != nil {
if err := codec.NewDecoderBytes(buf.Bytes(), codecHandle(msgpack)).Decode(&rep); err != nil {
return err
}
log.Debugf(
@@ -124,11 +124,6 @@ func MakeFromBinary(ctx context.Context, r io.Reader) (*Report, error) {
return &rep, nil
}
// ReadBytes reads bytes into a Report, using a codecHandle.
func (rep *Report) ReadBytes(buf []byte, codecHandle codec.Handle) error {
return codec.NewDecoderBytes(buf, codecHandle).Decode(&rep)
}
// MakeFromFile construct a Report from a file, with the encoding
// determined by the extension (".msgpack" or ".json", with an
// optional ".gz").