We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a4d3fb9 commit f054befCopy full SHA for f054bef
rlp/encode.go
@@ -21,6 +21,7 @@ import (
21
"fmt"
22
"io"
23
"math/big"
24
+ "math/bits"
25
"reflect"
26
27
"github.com/ethereum/go-ethereum/rlp/internal/rlpstruct"
@@ -487,9 +488,8 @@ func putint(b []byte, i uint64) (size int) {
487
488
489
// intsize computes the minimum number of bytes required to store i.
490
func intsize(i uint64) (size int) {
- for size = 1; ; size++ {
491
- if i >>= 8; i == 0 {
492
- return size
493
- }
+ if i == 0 {
+ return 1
494
}
+ return (bits.Len64(i) + 7) / 8
495
0 commit comments