use .UnsafeBytes() on easyjson since we're decoding hex anyway.
This commit is contained in:
@@ -35,9 +35,9 @@ func easyjsonF642ad3eDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Event)
|
||||
}
|
||||
switch key {
|
||||
case "id":
|
||||
hex.Decode(out.ID[:], []byte(in.String()))
|
||||
hex.Decode(out.ID[:], in.UnsafeBytes())
|
||||
case "pubkey":
|
||||
hex.Decode(out.PubKey[:], []byte(in.String()))
|
||||
hex.Decode(out.PubKey[:], in.UnsafeBytes())
|
||||
case "created_at":
|
||||
out.CreatedAt = Timestamp(in.Int64())
|
||||
case "kind":
|
||||
@@ -58,26 +58,24 @@ func easyjsonF642ad3eDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Event)
|
||||
out.Tags = (out.Tags)[:0]
|
||||
}
|
||||
for !in.IsDelim(']') {
|
||||
var v1 Tag
|
||||
var v Tag
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
v1 = nil
|
||||
v = nil
|
||||
} else {
|
||||
in.Delim('[')
|
||||
if !in.IsDelim(']') {
|
||||
v1 = make(Tag, 0, 5)
|
||||
v = make(Tag, 0, 5)
|
||||
} else {
|
||||
v1 = Tag{}
|
||||
v = Tag{}
|
||||
}
|
||||
for !in.IsDelim(']') {
|
||||
var v2 string
|
||||
v2 = in.String()
|
||||
v1 = append(v1, v2)
|
||||
v = append(v, in.String())
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim(']')
|
||||
}
|
||||
out.Tags = append(out.Tags, v1)
|
||||
out.Tags = append(out.Tags, v)
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim(']')
|
||||
@@ -85,7 +83,7 @@ func easyjsonF642ad3eDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Event)
|
||||
case "content":
|
||||
out.Content = in.String()
|
||||
case "sig":
|
||||
hex.Decode(out.Sig[:], []byte(in.String()))
|
||||
hex.Decode(out.Sig[:], in.UnsafeBytes())
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func easyjson4d398eaaDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Filter)
|
||||
}
|
||||
for !in.IsDelim(']') {
|
||||
id := [32]byte{}
|
||||
hex.Decode(id[:], []byte(in.String()))
|
||||
hex.Decode(id[:], in.UnsafeBytes())
|
||||
out.IDs = append(out.IDs, id)
|
||||
in.WantComma()
|
||||
}
|
||||
@@ -96,7 +96,7 @@ func easyjson4d398eaaDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Filter)
|
||||
}
|
||||
for !in.IsDelim(']') {
|
||||
pk := [32]byte{}
|
||||
hex.Decode(pk[:], []byte(in.String()))
|
||||
hex.Decode(pk[:], in.UnsafeBytes())
|
||||
out.Authors = append(out.Authors, pk)
|
||||
in.WantComma()
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func easyjson4d398eaaDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Filter)
|
||||
out.LimitZero = true
|
||||
}
|
||||
case "search":
|
||||
out.Search = string(in.String())
|
||||
out.Search = in.String()
|
||||
default:
|
||||
if len(key) > 1 && key[0] == '#' {
|
||||
tagValues := make([]string, 0, 40)
|
||||
@@ -144,9 +144,7 @@ func easyjson4d398eaaDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Filter)
|
||||
tagValues = (tagValues)[:0]
|
||||
}
|
||||
for !in.IsDelim(']') {
|
||||
var v3 string
|
||||
v3 = string(in.String())
|
||||
tagValues = append(tagValues, v3)
|
||||
tagValues = append(tagValues, in.String())
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim(']')
|
||||
@@ -259,7 +257,7 @@ func easyjson4d398eaaEncodeGithubComNbdWtfGoNostr(out *jwriter.Writer, in Filter
|
||||
} else {
|
||||
out.RawString(prefix)
|
||||
}
|
||||
out.String(string(in.Search))
|
||||
out.String(in.Search)
|
||||
}
|
||||
for tag, values := range in.Tags {
|
||||
const prefix string = ",\"authors\":"
|
||||
@@ -275,7 +273,7 @@ func easyjson4d398eaaEncodeGithubComNbdWtfGoNostr(out *jwriter.Writer, in Filter
|
||||
if i > 0 {
|
||||
out.RawByte(',')
|
||||
}
|
||||
out.String(string(v))
|
||||
out.String(v)
|
||||
}
|
||||
out.RawByte(']')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user