Try jsoniter in gmsl

This commit is contained in:
Neil Alexander 2021-01-25 15:04:01 +00:00
parent ef9d5ad4fe
commit 98dfaf3856
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
8 changed files with 26 additions and 18 deletions

View file

@ -20,6 +20,7 @@ import (
"fmt"
"github.com/Shopify/sarama"
jsoniter "github.com/json-iterator/go"
"github.com/matrix-org/dendrite/eduserver/api"
"github.com/matrix-org/dendrite/federationsender/queue"
"github.com/matrix-org/dendrite/federationsender/storage"
@ -131,7 +132,7 @@ func (t *OutputEDUConsumer) onSendToDeviceEvent(msg *sarama.ConsumerMessage) err
Sender: ote.Sender,
Type: ote.Type,
MessageID: util.RandomString(32),
Messages: map[string]map[string]json.RawMessage{
Messages: map[string]map[string]jsoniter.RawMessage{
ote.UserID: {
ote.DeviceID: ote.Content,
},

View file

@ -16,11 +16,11 @@ package queue
import (
"context"
"encoding/json"
"fmt"
"sync"
"time"
jsoniter "github.com/json-iterator/go"
"github.com/matrix-org/dendrite/federationsender/statistics"
"github.com/matrix-org/dendrite/federationsender/storage"
"github.com/matrix-org/dendrite/federationsender/storage/shared"
@ -367,7 +367,7 @@ func (oq *destinationQueue) nextTransaction(
// Create the transaction.
t := gomatrixserverlib.Transaction{
PDUs: []json.RawMessage{},
PDUs: []jsoniter.RawMessage{},
EDUs: []gomatrixserverlib.EDU{},
}
t.Origin = oq.origin
@ -390,7 +390,7 @@ func (oq *destinationQueue) nextTransaction(
if pdu == nil || pdu.pdu == nil {
continue
}
// Append the JSON of the event, since this is a json.RawMessage type in the
// Append the JSON of the event, since this is a jsoniter.RawMessage type in the
// gomatrixserverlib.Transaction struct
t.PDUs = append(t.PDUs, pdu.pdu.JSON())
pduReceipts = append(pduReceipts, pdu.receipt)