Skip to content

Commit

Permalink
Removed content-tree from regular dt dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
josephg committed Jul 19, 2024
1 parent 2c7b339 commit b0c1722
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 123 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ lazy_static = "1.4.0"
# Used by wasm module, CLI.
serde = { version = "1.0.183", features = ["derive"], optional = true }
rle = { version = "0.2.0", path = "crates/rle", features = ["smallvec"] }
content-tree = { version = "0.2.0", path = "crates/content-tree" }

# Only used for generating testing data.
serde_json = { version = "1.0.104", optional = true }
Expand Down Expand Up @@ -59,6 +58,9 @@ rand = { version = "0.8.5", features = ["small_rng"] }
crdt-testdata = { path = "crates/crdt-testdata" }
trace-alloc = { path = "crates/trace-alloc" }

# Only used for OST fuzz tests. TODO: Remove this.
content-tree = { version = "0.2.0", path = "crates/content-tree" }

# For OT fuzz data tests
#json_minimal = "0.1.3"

Expand Down
12 changes: 1 addition & 11 deletions src/causalgraph/agent_span.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO: Consider moving me into agent_assignment/.

use std::ops::Range;
use content_tree::ContentLength;
// use content_tree::ContentLength;
use rle::{HasLength, MergableSpan, Searchable, SplitableSpan, SplitableSpanHelpers};
use crate::AgentId;
use crate::dtrange::DTRange;
Expand Down Expand Up @@ -51,16 +51,6 @@ impl Searchable for AgentSpan {
}
}

impl ContentLength for AgentSpan {
fn content_len(&self) -> usize {
self.seq_range.len()
}

fn content_len_at_offset(&self, offset: usize) -> usize {
offset
}
}

impl HasLength for AgentSpan {
/// this length refers to the length that we'll use when we call truncate(). So this does count
/// deletes.
Expand Down
2 changes: 0 additions & 2 deletions src/listmerge/markers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ use std::ptr::NonNull;

use rle::{HasLength, MergableSpan, SplitableSpan, SplitableSpanHelpers};

use content_tree::*;
use rle::Searchable;
use crate::rev_range::RangeRev;
use crate::listmerge::DocRangeIndex;
use crate::listmerge::yjsspan::CRDTSpan;
use crate::list::operation::ListOpKind;
use crate::{DTRange, LV};
Expand Down
3 changes: 1 addition & 2 deletions src/listmerge/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::ptr::NonNull;
use jumprope::JumpRopeBuf;
use smartstring::alias::String as SmartString;

use content_tree::{DEFAULT_IE, DEFAULT_LE, NodeLeaf};
use rle::{AppendRle, HasLength, MergableSpan, MergeableIterator, Searchable, SplitableSpanCtx, Trim, TrimCtx};
use rle::intersect::rle_intersect_rev;

Expand All @@ -22,7 +21,7 @@ use crate::list::ListOpLog;
use crate::list::op_iter::OpMetricsIter;
use crate::list::op_metrics::{ListOperationCtx, ListOpMetrics};
use crate::list::operation::{ListOpKind, TextOperation};
use crate::listmerge::{DocRangeIndex, M2Tracker, Index};
use crate::listmerge::{M2Tracker, Index};
#[cfg(feature = "dot_export")]
use crate::listmerge::dot::DotColor::*;
use crate::listmerge::markers::{DelRange, Marker};
Expand Down
67 changes: 0 additions & 67 deletions src/listmerge/metrics.rs

This file was deleted.

6 changes: 0 additions & 6 deletions src/listmerge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
use std::pin::Pin;

use content_tree::ContentTreeRaw;

use crate::listmerge::markers::Marker;
use crate::listmerge::metrics::MarkerMetrics;
use crate::listmerge::yjsspan::CRDTSpan;
use crate::ost::content_tree::ContentTree;
use crate::ost::IndexTree;
Expand All @@ -25,7 +22,6 @@ pub(crate) mod merge;
pub(crate) mod markers;
mod advance_retreat;
// pub(crate) mod txn_trace;
mod metrics;
#[cfg(test)]
pub mod fuzzer;
#[cfg(feature = "dot_export")]
Expand All @@ -39,8 +35,6 @@ pub(crate) mod plan;

pub(crate) mod xf_old;

type DocRangeIndex = MarkerMetrics;

type Index = IndexTree<Marker>;

#[derive(Debug)]
Expand Down
66 changes: 35 additions & 31 deletions src/listmerge/yjsspan.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::fmt::{Debug, Formatter};
use content_tree::{ContentLength, Toggleable};
use rle::{HasLength, HasRleKey, MergableSpan, Searchable, SplitableSpan, SplitableSpanHelpers};
use crate::LV;
use crate::dtrange::{debug_lv, DTRange, UNDERWATER_START};
Expand Down Expand Up @@ -141,6 +140,11 @@ impl CRDTSpan {
pub fn end_state_len_at(&self, offset: usize) -> usize {
if self.end_state_ever_deleted { 0 } else { offset }
}

#[inline(always)]
pub fn content_len(&self) -> usize {
if self.current_state == INSERTED { self.len() } else { 0 }
}
}

// So the length is described in two ways - one for the current content position, and the other for
Expand Down Expand Up @@ -204,36 +208,36 @@ impl Searchable for CRDTSpan {
}
}

/// Content length corresponds to the current length (the length at the current state).
impl ContentLength for CRDTSpan {
#[inline(always)]
fn content_len(&self) -> usize {
if self.current_state == INSERTED { self.len() } else { 0 }
}

fn content_len_at_offset(&self, offset: usize) -> usize {
if self.current_state == INSERTED { offset } else { 0 }
}
}

impl Toggleable for CRDTSpan {
fn is_activated(&self) -> bool {
self.current_state == INSERTED
// self.state == Inserted && !self.ever_deleted
}

fn mark_activated(&mut self) {
panic!("Cannot mark activated");
// Not entirely sure this logic is right.
// self.state.undelete();
}

fn mark_deactivated(&mut self) {
// debug_assert!(!self.is_deleted);
// self.state.delete();
self.delete();
}
}
// /// Content length corresponds to the current length (the length at the current state).
// impl ContentLength for CRDTSpan {
// #[inline(always)]
// fn content_len(&self) -> usize {
// if self.current_state == INSERTED { self.len() } else { 0 }
// }
//
// fn content_len_at_offset(&self, offset: usize) -> usize {
// if self.current_state == INSERTED { offset } else { 0 }
// }
// }
//
// impl Toggleable for CRDTSpan {
// fn is_activated(&self) -> bool {
// self.current_state == INSERTED
// // self.state == Inserted && !self.ever_deleted
// }
//
// fn mark_activated(&mut self) {
// panic!("Cannot mark activated");
// // Not entirely sure this logic is right.
// // self.state.undelete();
// }
//
// fn mark_deactivated(&mut self) {
// // debug_assert!(!self.is_deleted);
// // self.state.delete();
// self.delete();
// }
// }

// impl HasRleKey for CRDTSpan {
// fn rle_key(&self) -> usize {
Expand Down
1 change: 0 additions & 1 deletion src/listmerge2/yjsspan.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::fmt::{Debug, Formatter};
use content_tree::{ContentLength, Toggleable};
use rle::{HasLength, MergableSpan, Searchable, SplitableSpan, SplitableSpanHelpers};
use crate::{DTRange, LV};

Expand Down
1 change: 0 additions & 1 deletion src/ost/content_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::mem;
use std::mem::{replace, take};
use std::ops::{Index, IndexMut, Range, Sub};
use std::ptr::NonNull;
use content_tree::{NodeLeaf, UnsafeCursor};
use rle::{HasLength, HasRleKey, MergableSpan, MergeableIterator, RleDRun, Searchable, SplitableSpan, SplitableSpanHelpers};
use crate::{DTRange, LV};
use crate::ost::{LEAF_CHILDREN, LeafIdx, LenPair, LenUpdate, NODE_CHILDREN, NodeIdx, remove_from_array, remove_from_array_fill};
Expand Down
1 change: 0 additions & 1 deletion src/ost/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use std::iter::Sum;
pub(crate) use index_tree::{IndexContent, IndexTree};

use std::ops::{Add, AddAssign, Index, IndexMut, Range, Sub, SubAssign};
use ::content_tree::ContentLength;
use rle::{HasLength, MergableSpan, SplitableSpan};
use crate::listmerge::yjsspan::CRDTSpan;
// use crate::ost::content_tree::ContentTree;
Expand Down

0 comments on commit b0c1722

Please sign in to comment.