mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
rlp: opt intsize
This commit is contained in:
parent
a4d3fb9805
commit
789452a5d8
1 changed files with 4 additions and 4 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"math/bits"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/rlp/internal/rlpstruct"
|
"github.com/ethereum/go-ethereum/rlp/internal/rlpstruct"
|
||||||
|
|
@ -487,9 +488,8 @@ func putint(b []byte, i uint64) (size int) {
|
||||||
|
|
||||||
// intsize computes the minimum number of bytes required to store i.
|
// intsize computes the minimum number of bytes required to store i.
|
||||||
func intsize(i uint64) (size int) {
|
func intsize(i uint64) (size int) {
|
||||||
for size = 1; ; size++ {
|
if i == 0 {
|
||||||
if i >>= 8; i == 0 {
|
return 1
|
||||||
return size
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return (bits.Len64(i) + 7) / 8
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue