Skip to content

Commit f62ed09

Browse files
committed
perf(json-crdt): ⚡️ improve node size retrieval for binary encoding
1 parent 1b62250 commit f62ed09

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Structural Codecs
22

3-
Structural codecs encode the hierarchical structure of the document.
3+
Structural codecs encode the hierarchical structure of the document. Indexed
4+
codecs encode the document as a flat map of nodes.

src/json-crdt/codec/structural/binary/Encoder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class Encoder extends CborEncoder<CrdtWriter> {
125125
const ts = this.ts;
126126
const writer = this.writer;
127127
ts(node.id);
128-
this.writeTL(CRDT_MAJOR_OVERLAY.ARR, node.size());
128+
this.writeTL(CRDT_MAJOR_OVERLAY.ARR, node.count);
129129
const index = this.doc.index;
130130
for (let chunk = node.first(); chunk; chunk = node.next(chunk)) {
131131
const span = chunk.span;
@@ -142,7 +142,7 @@ export class Encoder extends CborEncoder<CrdtWriter> {
142142
const ts = this.ts;
143143
const writer = this.writer;
144144
ts(node.id);
145-
this.writeTL(CRDT_MAJOR_OVERLAY.STR, node.size());
145+
this.writeTL(CRDT_MAJOR_OVERLAY.STR, node.count);
146146
for (let chunk = node.first(); chunk; chunk = node.next(chunk)) {
147147
ts(chunk.id);
148148
if (chunk.del) {
@@ -156,7 +156,7 @@ export class Encoder extends CborEncoder<CrdtWriter> {
156156
const ts = this.ts;
157157
const writer = this.writer;
158158
ts(node.id);
159-
this.writeTL(CRDT_MAJOR_OVERLAY.BIN, node.size());
159+
this.writeTL(CRDT_MAJOR_OVERLAY.BIN, node.count);
160160
for (let chunk = node.first(); chunk; chunk = node.next(chunk)) {
161161
const length = chunk.span;
162162
const deleted = chunk.del;

0 commit comments

Comments
 (0)