From 72045dff4f766d4b8332f126e377ab54a683276e Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 5 Sep 2019 13:19:55 +0200 Subject: core/state: optimize some internals during encoding --- common/bytes.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'common') diff --git a/common/bytes.go b/common/bytes.go index 910c97d3c..fa457b92c 100644 --- a/common/bytes.go +++ b/common/bytes.go @@ -134,3 +134,14 @@ func LeftPadBytes(slice []byte, l int) []byte { return padded } + +// TrimLeftZeroes returns a subslice of s without leading zeroes +func TrimLeftZeroes(s []byte) []byte { + idx := 0 + for ; idx < len(s); idx++ { + if s[idx] != 0 { + break + } + } + return s[idx:] +} -- cgit v1.2.3