mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
avoid trigger memory reallocation of slice
This commit is contained in:
parent
7cfff30ba3
commit
25dcb2e67c
1 changed files with 4 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/crate-crypto/go-ipa/bandersnatch/fr"
|
"github.com/crate-crypto/go-ipa/bandersnatch/fr"
|
||||||
|
|
@ -307,9 +308,7 @@ func pointToHash(evaluated *verkle.Point, suffix byte) []byte {
|
||||||
// tree would be empty. To avoid this problem, use a little
|
// tree would be empty. To avoid this problem, use a little
|
||||||
// endian commitment and chop the MSB.
|
// endian commitment and chop the MSB.
|
||||||
bytes := evaluated.Bytes()
|
bytes := evaluated.Bytes()
|
||||||
for i := 0; i < 16; i++ {
|
slices.Reverse(bytes[:])
|
||||||
bytes[31-i], bytes[i] = bytes[i], bytes[31-i]
|
|
||||||
}
|
|
||||||
bytes[31] = suffix
|
bytes[31] = suffix
|
||||||
return bytes[:]
|
return bytes[:]
|
||||||
}
|
}
|
||||||
|
|
@ -317,7 +316,8 @@ func pointToHash(evaluated *verkle.Point, suffix byte) []byte {
|
||||||
func evaluateAddressPoint(address []byte) *verkle.Point {
|
func evaluateAddressPoint(address []byte) *verkle.Point {
|
||||||
if len(address) < 32 {
|
if len(address) < 32 {
|
||||||
var aligned [32]byte
|
var aligned [32]byte
|
||||||
address = append(aligned[:32-len(address)], address...)
|
copy(aligned[32-len(address):], address)
|
||||||
|
address = aligned[:]
|
||||||
}
|
}
|
||||||
var poly [3]fr.Element
|
var poly [3]fr.Element
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue