mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-18 03:46:45 +00:00
refactor: eliminate ReadBytes() function that is only called once
This commit is contained in:
+1
-6
@@ -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").
|
||||
|
||||
Reference in New Issue
Block a user