Browse Source

Refactor Marshal function in filter encoder

- 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.
main
mleku 3 months ago
parent
commit
df67538af2
No known key found for this signature in database
  1. 20
      pkg/encoders/filter/filter.go
  2. 2
      pkg/version/version

20
pkg/encoders/filter/filter.go

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

2
pkg/version/version

@ -1 +1 @@ @@ -1 +1 @@
v0.19.8
v0.19.9
Loading…
Cancel
Save