From 241d5f593edebfb8175afc74d820de60580f2aa8 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 11 Oct 2023 15:41:04 +0300 Subject: [PATCH] *: use methods of binary.AppendByteOrder where applicable We often use binary.PutUint*, but almost all these cases have preallocated buffer of the size that matches exactly the desired one and use a single or a couple of calls to PutUint*. Thus, I don't think that replacing binary.PutUint* by AppendUint* will make things better for all these usages. Signed-off-by: Anna Shaleva --- pkg/core/dao/dao.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index c5a6ef4ca..975bacca2 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -499,8 +499,8 @@ func (v *Version) Bytes() []byte { if v.KeepOnlyLatestState { mask |= keepOnlyLatestStateBit } - res := append([]byte(v.Value), '\x00', byte(v.StoragePrefix), mask, 0, 0, 0, 0) - binary.LittleEndian.PutUint32(res[len(res)-4:], v.Magic) + res := append([]byte(v.Value), '\x00', byte(v.StoragePrefix), mask) + res = binary.LittleEndian.AppendUint32(res, v.Magic) return res }