From 0fc00d8a68eab614c6d83b5dc88a1fa05b001b17 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 7 Apr 2025 15:14:56 -0300 Subject: [PATCH] sdk/hints: eliminate two unnecessary unsafe conversions on copy. --- sdk/hints/badgerh/keys.go | 3 +-- sdk/hints/lmdbh/keys.go | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sdk/hints/badgerh/keys.go b/sdk/hints/badgerh/keys.go index 5c74f18..3673a4b 100644 --- a/sdk/hints/badgerh/keys.go +++ b/sdk/hints/badgerh/keys.go @@ -3,7 +3,6 @@ package badgerh import ( "encoding/binary" "encoding/hex" - "unsafe" "github.com/nbd-wtf/go-nostr" ) @@ -11,7 +10,7 @@ import ( func encodeKey(pubhintkey, relay string) []byte { k := make([]byte, 32+len(relay)) hex.Decode(k[0:32], []byte(pubhintkey)) - copy(k[32:], unsafe.Slice(unsafe.StringData(relay), len(relay))) + copy(k[32:], relay) return k } diff --git a/sdk/hints/lmdbh/keys.go b/sdk/hints/lmdbh/keys.go index bd6a89e..2ff5c1c 100644 --- a/sdk/hints/lmdbh/keys.go +++ b/sdk/hints/lmdbh/keys.go @@ -3,7 +3,6 @@ package lmdbh import ( "encoding/binary" "encoding/hex" - "unsafe" "github.com/nbd-wtf/go-nostr" ) @@ -11,7 +10,7 @@ import ( func encodeKey(pubhintkey, relay string) []byte { k := make([]byte, 32+len(relay)) hex.Decode(k[0:32], []byte(pubhintkey)) - copy(k[32:], unsafe.Slice(unsafe.StringData(relay), len(relay))) + copy(k[32:], relay) return k } @@ -37,4 +36,4 @@ func parseValue(v []byte) timestamps { nostr.Timestamp(binary.LittleEndian.Uint32(v[8:])), nostr.Timestamp(binary.LittleEndian.Uint32(v[12:])), } -} \ No newline at end of file +}