mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-26 05:31:28 +02:00
ridiculous performance string and serialization performance improvements.
This commit is contained in:
16
event.go
16
event.go
@@ -3,7 +3,7 @@ package nostr
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/mailru/easyjson"
|
||||
)
|
||||
@@ -60,13 +60,13 @@ func (evt *Event) Serialize() []byte {
|
||||
|
||||
// the header portion is easy to serialize
|
||||
// [0,"pubkey",created_at,kind,[
|
||||
dst = append(dst, []byte(
|
||||
fmt.Sprintf(
|
||||
"[0,\"%s\",%d,%d,",
|
||||
evt.PubKey,
|
||||
evt.CreatedAt,
|
||||
evt.Kind,
|
||||
))...)
|
||||
dst = append(dst, "[0,\""...)
|
||||
dst = append(dst, evt.PubKey...)
|
||||
dst = append(dst, "\","...)
|
||||
dst = append(dst, strconv.FormatInt(int64(evt.CreatedAt), 10)...)
|
||||
dst = append(dst, ',')
|
||||
dst = append(dst, strconv.Itoa(evt.Kind)...)
|
||||
dst = append(dst, ',')
|
||||
|
||||
// tags
|
||||
dst = evt.Tags.marshalTo(dst)
|
||||
|
Reference in New Issue
Block a user