mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-13 19:46:39 +00:00
p2p/rlpx: optimize XOR operation using bitutil.XORBytes (#32217)
Replace manual byte-by-byte XOR implementation with the optimized bitutil.XORBytes function. This improves performance by using word-sized operations on supported architectures while maintaining the same functionality. The optimized version processes data in bulk rather than one byte at a time --------- Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
264c06a72c
commit
a7efdcbf09
1 changed files with 2 additions and 3 deletions
|
|
@ -33,6 +33,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common/bitutil"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/crypto/ecies"
|
"github.com/ethereum/go-ethereum/crypto/ecies"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
|
|
@ -676,8 +677,6 @@ func exportPubkey(pub *ecies.PublicKey) []byte {
|
||||||
|
|
||||||
func xor(one, other []byte) (xor []byte) {
|
func xor(one, other []byte) (xor []byte) {
|
||||||
xor = make([]byte, len(one))
|
xor = make([]byte, len(one))
|
||||||
for i := 0; i < len(one); i++ {
|
bitutil.XORBytes(xor, one, other)
|
||||||
xor[i] = one[i] ^ other[i]
|
|
||||||
}
|
|
||||||
return xor
|
return xor
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue