diff options
author | Martin Holst Swende <martin@swende.se> | 2019-09-05 19:19:55 +0800 |
---|---|---|
committer | Martin Holst Swende <martin@swende.se> | 2019-09-10 21:15:34 +0800 |
commit | 72045dff4f766d4b8332f126e377ab54a683276e (patch) | |
tree | feef6f37c21a61939c8c20339ababd0e2f6182cc /common/bytes.go | |
parent | 67bfc9305324ef73267856f26752904715be312d (diff) | |
download | go-tangerine-72045dff4f766d4b8332f126e377ab54a683276e.tar go-tangerine-72045dff4f766d4b8332f126e377ab54a683276e.tar.gz go-tangerine-72045dff4f766d4b8332f126e377ab54a683276e.tar.bz2 go-tangerine-72045dff4f766d4b8332f126e377ab54a683276e.tar.lz go-tangerine-72045dff4f766d4b8332f126e377ab54a683276e.tar.xz go-tangerine-72045dff4f766d4b8332f126e377ab54a683276e.tar.zst go-tangerine-72045dff4f766d4b8332f126e377ab54a683276e.zip |
core/state: optimize some internals during encoding
Diffstat (limited to 'common/bytes.go')
-rw-r--r-- | common/bytes.go | 11 |
1 files changed, 11 insertions, 0 deletions
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:] +} |