Closed ObuchiYuki closed 11 months ago
Hi @ObuchiYuki,
I should add more documentation on this. The idea is that you call toUint8Array
only once to serialize the data. Serializing it several times is not supposed to work. It's also not supported by the other RLE encoders - to decrease complexity. Instead, you could create a new RLE encoder if you want to encode new data.
What's the use-case for calling toUint8Array
twice?
FYI: We are also working on a Swift binding based on uniffi: https://github.com/y-crdt/y-uniffi
Describe the bug After writing the content to
IntDiffOptRleEncoder
(alsoUintOptRleEncoder
,IncUintOptRleEncoder
), when reading the content withtoUint8Array()
, the content is different each time due to flush.Expected behavior Since
toUint8Array()
is obviously a function for reading values, its contents should not change with each call.To fix
IntDiffOptRleEncoder
should have a flag like mutated. In that case, the implementation would be as followsAppendices In yjs, there is no part of
IntDiffOptRleEncoder
that callstoUint8Array()
twice. I also confirmed thatIntDiffOptRleEncoder
with this modification passes all tests in yjs.(I am personally working on yjs for Swift yswift. I discovered this in debugging).