IEEE-NITK / codeshare

A web-based code editor for real time collaborative editing
3 stars 6 forks source link

Remove [0, -1] Identifier at the start of every character #13

Open shanthanu9 opened 4 years ago

shanthanu9 commented 4 years ago

When the editor has

abc
def

The CRDT structure is

{: [[0, -1]]}, {a: [[0, -1], [1, 2]]}, {b: [[0, -1], [2, 2]]}, {c: [[0, -1], [3, 2]]}, {: [[0, -1], [4, -1]]}
{: [[0, -1], [4, -1]]}, {d: [[0, -1], [4, 2]]}, {e: [[0, -1], [5, 2]]}, {f: [[0, -1], [6, 2]]}, {: [[1, Infinity]]}

Every character has the [0, -1] identifier at the beginning. So while pushing operations to the channel, the first [0, -1] identifier can be skipped and when receiving operation, the [0, -1] identifier can be added back.

Saves network bandwidth and database storage space.