rinq / rinq-go

A cross-language command bus and distributed ephemeral data store.
Other
17 stars 1 forks source link

Avoid unnecessary encode+decode in `Payload.Decode()` #125

Open jmalloc opened 7 years ago

jmalloc commented 7 years ago

If a payload is created from a value (as opposed to a byte slice) it does not have a CBOR representation. If Decode() is called, the value is first encoded, then immediately unencoded. Whilst this does ensure that the semantics of decode are always the same, it is completely unnecessary.

Instead, we should use reflection to assign to the decode target in much the same way as codec's decoder.Decode().