mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-09 00:52:49 +02:00
sdk/hints: eliminate two unnecessary unsafe conversions on copy.
This commit is contained in:
@@ -3,7 +3,6 @@ package badgerh
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
)
|
)
|
||||||
@@ -11,7 +10,7 @@ import (
|
|||||||
func encodeKey(pubhintkey, relay string) []byte {
|
func encodeKey(pubhintkey, relay string) []byte {
|
||||||
k := make([]byte, 32+len(relay))
|
k := make([]byte, 32+len(relay))
|
||||||
hex.Decode(k[0:32], []byte(pubhintkey))
|
hex.Decode(k[0:32], []byte(pubhintkey))
|
||||||
copy(k[32:], unsafe.Slice(unsafe.StringData(relay), len(relay)))
|
copy(k[32:], relay)
|
||||||
return k
|
return k
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,6 @@ package lmdbh
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
)
|
)
|
||||||
@@ -11,7 +10,7 @@ import (
|
|||||||
func encodeKey(pubhintkey, relay string) []byte {
|
func encodeKey(pubhintkey, relay string) []byte {
|
||||||
k := make([]byte, 32+len(relay))
|
k := make([]byte, 32+len(relay))
|
||||||
hex.Decode(k[0:32], []byte(pubhintkey))
|
hex.Decode(k[0:32], []byte(pubhintkey))
|
||||||
copy(k[32:], unsafe.Slice(unsafe.StringData(relay), len(relay)))
|
copy(k[32:], relay)
|
||||||
return k
|
return k
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user