From 0002803135300580da97b3a271a6ab4f0b2a4d20 Mon Sep 17 00:00:00 2001 From: Charlotte Som Date: Thu, 6 Mar 2025 11:23:32 +0000 Subject: [PATCH] get rid of the slow implementation of plaintext stuff since i have this project in version control now there's not really any reason to keep large block comments of defunct code around --- sync/ordt/plain-text.ts | 51 ----------------------------------------- 1 file changed, 51 deletions(-) diff --git a/sync/ordt/plain-text.ts b/sync/ordt/plain-text.ts index 9a25d37..859e5d7 100644 --- a/sync/ordt/plain-text.ts +++ b/sync/ordt/plain-text.ts @@ -106,55 +106,4 @@ export class PlainTextORDT extends CausalTree { } return [s, metadata] as const; } - - /* very slow, uncached: - findOpAtTextIndex(textIndex: number): number { - const [_string, metadata] = this.render(); - - for (const meta of metadata) { - if (meta.start < textIndex && textIndex <= meta.end) - return this.operations.findIndex(it => it === meta.op); - } - return -1; - } - - render() { - const s: string[] = []; - const metadata = []; - let length = 0; - for (const op of this.operations) { - if (op.type === "insert") { - s.push(op.sequence); - metadata.push({ - op, - start: length, - end: length + op.sequence.length, - }); - length += op.sequence.length; - } - if (op.type === "delete") { - if (!op.parent) continue; - if (op.parent.type !== "insert") continue; - - const len = op.parent.sequence.length; - length -= len; - - // since we expect to be tacked on close to the referenced op, - // we can quickly seek back from current position - // (it should only take a few iterations - usually 1) - for (let idx = metadata.length - 1; idx >= 0; idx--) { - const m = metadata[idx]; - m.start -= len; - m.end -= len; - if (m.op === op.parent) { - s.splice(idx, 1); - metadata.splice(idx, 1); - break; - } - } - } - } - - return [s.join(""), metadata] as const; - } */ } -- 2.51.2