Skip to content

Commit

Permalink
test: add diagnose info for id_to_cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Oct 30, 2023
1 parent 091a3d4 commit adb5056
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/loro-internal/src/container/richtext/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ impl Tracker {
self._checkout(from, false);
self._checkout(to, true);
// debug_log::debug_dbg!(from, to, &self);
self.id_to_cursor.diagnose();
self.rope.get_diff()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ impl IdToCursor {
.cursor
.get_insert((id.counter - list[index].counter) as usize)
}

pub fn diagnose(&self) {
let fragment_num = self.map.iter().map(|x| x.1.len()).sum::<usize>();
let insert_pieces = self
.map
.iter()
.flat_map(|x| x.1.iter())
.map(|x| match &x.cursor {
Cursor::Insert { set, len } => set.len(),
Cursor::Delete(_) => 0,
})
.sum::<usize>();
eprintln!(
"fragments:{}, insert_pieces:{}",
fragment_num, insert_pieces
);
}
}

#[derive(Debug)]
Expand Down

0 comments on commit adb5056

Please sign in to comment.