core/state: optimize some internals during encoding

This commit is contained in:
Martin Holst Swende
2019-09-05 13:19:55 +02:00
parent 67bfc93053
commit 72045dff4f
3 changed files with 82 additions and 1 deletions

View File

@ -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:]
}