diff --git a/y-octo/src/doc/document.rs b/y-octo/src/doc/document.rs index 148d86e..a180ffc 100644 --- a/y-octo/src/doc/document.rs +++ b/y-octo/src/doc/document.rs @@ -220,16 +220,15 @@ impl Doc { Ok(doc) } - pub fn apply_update_from_binary_v1>(&mut self, binary: T) -> JwstCodecResult { + pub fn apply_update_from_binary_v1>(&mut self, binary: T) -> JwstCodecResult { let mut decoder = RawDecoder::new(binary.as_ref()); let update = Update::read(&mut decoder)?; self.apply_update(update) } - pub fn apply_update(&mut self, mut update: Update) -> JwstCodecResult { + pub fn apply_update(&mut self, mut update: Update) -> JwstCodecResult { let mut store = self.store.write().unwrap(); let mut retry = false; - let before_state = store.get_state_vector(); loop { for (mut s, offset) in update.iter(store.get_state_vector()) { if let Node::Item(item) = &mut s { @@ -288,7 +287,7 @@ impl Doc { } } - store.diff_state_vector(&before_state, false) + Ok(()) } pub fn keys(&self) -> Vec { diff --git a/y-octo/src/doc/store.rs b/y-octo/src/doc/store.rs index cb5ac95..cea9364 100644 --- a/y-octo/src/doc/store.rs +++ b/y-octo/src/doc/store.rs @@ -780,7 +780,6 @@ impl DocStore { let first_block = items.get(index).unwrap(); let offset = first_block.clock() - clock; if offset != 0 { - // needs to implement Content split first vec_struct_info.push_back(first_block.clone().split_at(offset)?.1); } else { vec_struct_info.push_back(first_block.clone()); @@ -800,17 +799,10 @@ impl DocStore { let mut delete_set = DeleteSet::default(); for (client, nodes) in refs { - let ranges = nodes + nodes .iter() .filter(|n| n.deleted()) - .map(|n| { - let clock = n.id().clock; - clock..clock + n.len() - }) - .collect::>(); - if !ranges.is_empty() { - delete_set.batch_add_ranges(*client, ranges); - } + .for_each(|n| delete_set.add(*client, n.clock(), n.len())); } delete_set