mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Call Must(En|De)code instead of (En|De)code to save time
Encode/Decode returns an error code, which we are generally not checking for sub-objects because we never expect it to fail. In the new version of codegen Encode() sets up a panic handler and calls MustEncode(), and the panic handler has a performance cost. So just call MustEncode() and if for some reason the encoding does fail we will see it as a panic. We still call Encode/Decode at top level and check the return code.
This commit is contained in:
@@ -114,7 +114,7 @@ func (s Sets) DeepEqual(t Sets) bool {
|
||||
// CodecEncodeSelf implements codec.Selfer
|
||||
func (s *Sets) CodecEncodeSelf(encoder *codec.Encoder) {
|
||||
mapWrite(s.psMap, encoder, func(encoder *codec.Encoder, val interface{}) {
|
||||
encoder.Encode(val.(StringSet))
|
||||
encoder.MustEncode(val.(StringSet))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func (s *Sets) CodecDecodeSelf(decoder *codec.Decoder) {
|
||||
out := mapRead(decoder, func(isNil bool) interface{} {
|
||||
var value StringSet
|
||||
if !isNil {
|
||||
decoder.Decode(&value)
|
||||
decoder.MustDecode(&value)
|
||||
}
|
||||
return value
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user