Skip to content

Commit 4f8c968

Browse files
committed
perf(json-crdt-extensions): ⚡️ improve backward iteration end condition check
1 parent 0358fdd commit 4f8c968

File tree

1 file changed

+1
-3
lines changed
  • src/json-crdt-extensions/peritext/editor

1 file changed

+1
-3
lines changed

src/json-crdt-extensions/peritext/editor/Editor.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ export class Editor<T = string> {
115115
const str = this.txt.str;
116116
return () => {
117117
if (!chunk) return;
118+
const span = chunk.span;
118119
const offsetToReturn = offset;
119120
const chunkToReturn = chunk;
120-
const span = chunk.span;
121121
if (offset >= span) return;
122122
offset++;
123123
if (offset >= span) {
@@ -163,8 +163,6 @@ export class Editor<T = string> {
163163
if (!chunk || offset < 0) return;
164164
const offsetToReturn = offset;
165165
const chunkToReturn = chunk;
166-
const char = chunkToReturn.view().slice(offsetToReturn, offsetToReturn + 1);
167-
if (!char) return;
168166
offset--;
169167
if (offset < 0) {
170168
chunk = str.prev(chunk);

0 commit comments

Comments
 (0)