Refactor Marshal function in filter encoder
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled

- Simplified the key-value appending logic in the Marshal function by replacing manual string appending with the text.AppendQuote method for better readability and maintainability.
- Updated version number to v0.19.9 to reflect the changes made.
This commit is contained in:
2025-10-28 19:23:27 +00:00
parent f5d13a6807
commit df67538af2
2 changed files with 10 additions and 12 deletions

View File

@@ -208,18 +208,16 @@ func (f *F) Marshal(dst []byte) (b []byte) {
} else { } else {
first = true first = true
} }
// append the key with # prefix // append the key with # prefix
dst = append(dst, '"', '#', tKey[0], '"', ':') dst = append(dst, '"', '#', tKey[0], '"', ':')
dst = append(dst, '[') dst = append(dst, '[')
for i, value := range values { for i, value := range values {
dst = append(dst, '"') dst = text.AppendQuote(dst, value, text.NostrEscape)
dst = append(dst, value...) if i < len(values)-1 {
dst = append(dst, '"') dst = append(dst, ',')
if i < len(values)-1 {
dst = append(dst, ',')
}
} }
dst = append(dst, ']') }
dst = append(dst, ']')
} }
} }
if f.Since != nil && f.Since.U64() > 0 { if f.Since != nil && f.Since.U64() > 0 {

View File

@@ -1 +1 @@
v0.19.8 v0.19.9