This commit is contained in:
2026-06-09 16:42:17 +00:00
parent 7007b1b6fd
commit 4089ca40c9
11 changed files with 597 additions and 406 deletions

View File

@@ -205,7 +205,7 @@ func (s *CumulativeDeltaCompressor) Size() int {
if s.state == nil {
return s.pos
} else {
return len(s.state.Payload)
return bin.CountVarUint64(s.state.LastDelta) + hSize + len(s.state.Payload)
}
}
@@ -220,18 +220,9 @@ func (s *CumulativeDeltaCompressor) Payload() []byte {
func (s *CumulativeDeltaCompressor) WritePayloadTo(w io.Writer) (err error) {
if s.state == nil {
err = bin.WriteUint16(w, uint16(s.pos))
if err != nil {
return
}
_, err = w.Write(s.buf[:s.pos])
return
} else {
size := bin.CountVarUint64(s.state.LastDelta) + hSize + len(s.state.Payload)
err = bin.WriteUint16(w, uint16(size))
if err != nil {
return
}
_, err = w.Write(s.state.Payload)
if err != nil {
return
@@ -240,7 +231,7 @@ func (s *CumulativeDeltaCompressor) WritePayloadTo(w io.Writer) (err error) {
if err != nil {
return
}
w.Write([]byte{
_, err = w.Write([]byte{
s.state.H,
})
return