Skip to content

Commit

Permalink
skip useless deltas in recovered publications
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Jun 9, 2024
1 parent 47f117d commit 09caeab
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3038,24 +3038,21 @@ func (c *Client) makeRecoveredPubsDeltaFossil(recoveredPubs []*protocol.Publicat
if len(recoveredPubs) > 1 {
for i, pub := range recoveredPubs[1:] {
patch := fdelta.Create(prevPub.Data, pub.Data)
var deltaPub *protocol.Publication
delta := true
deltaData := patch
if len(patch) >= len(pub.Data) {
delta = false
deltaData = pub.Data
}
if c.transport.Protocol() == ProtocolTypeJSON {
// For JSON case we need to use JSON string (js) for patch.
deltaPub = &protocol.Publication{
Offset: pub.Offset,
Data: json.Escape(convert.BytesToString(patch)),
Info: pub.Info,
Tags: pub.Tags,
Delta: true,
}
} else {
deltaPub = &protocol.Publication{
Offset: pub.Offset,
Data: patch,
Info: pub.Info,
Tags: pub.Tags,
Delta: true,
}
deltaData = json.Escape(convert.BytesToString(deltaData))
}
deltaPub := &protocol.Publication{
Offset: pub.Offset,
Data: deltaData,
Info: pub.Info,
Tags: pub.Tags,
Delta: delta,
}
recoveredPubs[i+1] = deltaPub
prevPub = recoveredPubs[i]
Expand Down

0 comments on commit 09caeab

Please sign in to comment.