transaction: avoid reencoding and reading what can't be read
name old time/op new time/op delta DecodeFromBytes-8 1.79µs ± 2% 1.46µs ± 4% -18.44% (p=0.000 n=10+10) name old alloc/op new alloc/op delta DecodeFromBytes-8 800B ± 0% 624B ± 0% -22.00% (p=0.000 n=10+10) name old allocs/op new allocs/op delta DecodeFromBytes-8 10.0 ± 0% 8.0 ± 0% -20.00% (p=0.000 n=10+10)
This commit is contained in:
parent
d0620b24ec
commit
7808762ba0
4 changed files with 35 additions and 15 deletions
|
@ -29,8 +29,7 @@ func NewP2PNotaryRequestFromBytes(b []byte) (*P2PNotaryRequest, error) {
|
|||
if br.Err != nil {
|
||||
return nil, br.Err
|
||||
}
|
||||
_ = br.ReadB()
|
||||
if br.Err == nil {
|
||||
if br.Len() != 0 {
|
||||
return nil, errors.New("additional data after the payload")
|
||||
}
|
||||
return req, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue