use IndexByte instead of IndexRune everywhere because it's faster.

This commit is contained in:
fiatjaf
2025-05-05 23:37:43 -03:00
parent 3723924561
commit 0ae2316523
4 changed files with 9 additions and 9 deletions

View File

@@ -14,11 +14,11 @@ func NewMessageParser() MessageParser {
type messageParser struct{}
func (messageParser) ParseMessage(message string) (Envelope, error) {
firstQuote := strings.IndexRune(message, '"')
firstQuote := strings.IndexByte(message, '"')
if firstQuote == -1 {
return nil, errors.New("malformed json")
}
secondQuote := strings.IndexRune(message[firstQuote+1:], '"')
secondQuote := strings.IndexByte(message[firstQuote+1:], '"')
if secondQuote == -1 {
return nil, errors.New("malformed json")
}