remove sonic from the default build, guard it under "sonic" tag for now.

This commit is contained in:
fiatjaf
2025-03-10 17:33:32 -03:00
parent 74e121075e
commit 657c6edf6c
4 changed files with 69 additions and 4 deletions

View File

@@ -1,3 +1,5 @@
//go:build sonic
package nostr
import (
@@ -360,6 +362,8 @@ func (sv *sonicVisitor) OnString(v string) error {
sv.whereWeAre = inClosed
case "NOTICE":
sv.whereWeAre = inNotice
default:
return UnknownLabel
}
// in an envelope
@@ -483,9 +487,9 @@ type sonicMessageParser struct {
reusableIntArray []int
}
// NewSonicMessageParser returns a sonicMessageParser object that is intended to be reused many times.
// NewMessageParser returns a sonicMessageParser object that is intended to be reused many times.
// It is not goroutine-safe.
func NewSonicMessageParser() sonicMessageParser {
func NewMessageParser() sonicMessageParser {
return sonicMessageParser{
reusableFilterArray: make([]Filter, 0, 1000),
reusableTagArray: make([]Tag, 0, 10000),
@@ -494,6 +498,8 @@ func NewSonicMessageParser() sonicMessageParser {
}
}
var NewSonicMessageParser = NewMessageParser
func (smp *sonicMessageParser) doneWithFilterSlice(slice []Filter) {
if unsafe.SliceData(smp.reusableFilterArray) == unsafe.SliceData(slice) {
smp.reusableFilterArray = slice[len(slice):]