Skip to content

Commit

Permalink
Remove root field from SyntaxInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
QuarticCat committed Oct 11, 2022
1 parent adf6077 commit 1ede273
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
12 changes: 0 additions & 12 deletions src/diff/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ impl<'a> SideSyntax<'a> {
}
}

pub fn root(&self) -> Option<&'a Syntax<'a>> {
match self.get_side() {
Some(side) => Some(side.root()),
None => match self.data ^ 1 {
0 => None,
d => Some(unsafe { &*(d as *const Syntax<'a>) }.root()),
},
}
}

pub fn from_side(side: &'a Syntax<'a>) -> Self {
Self {
data: side as *const _ as _,
Expand Down Expand Up @@ -209,8 +199,6 @@ impl<'a, 'b> Vertex<'a, 'b> {
fn parents_eq(&self, other: &Vertex<'a, 'b>) -> bool {
self.lhs_parent_stack == other.lhs_parent_stack
&& self.rhs_parent_stack == other.rhs_parent_stack
&& self.lhs_syntax.root() == other.lhs_syntax.root()
&& self.rhs_syntax.root() == other.rhs_syntax.root()
}

fn can_pop_either(&self) -> bool {
Expand Down
26 changes: 0 additions & 26 deletions src/parse/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ pub struct SyntaxInfo<'a> {
prev: Cell<Option<&'a Syntax<'a>>>,
/// The parent syntax node, if present.
parent: Cell<Option<&'a Syntax<'a>>>,
/// The root syntax node.
root: Cell<Option<&'a Syntax<'a>>>,
/// Does the previous syntax node occur on the same line as the
/// first line of this node?
prev_is_contiguous: Cell<bool>,
Expand All @@ -75,7 +73,6 @@ impl<'a> SyntaxInfo<'a> {
next_sibling: Cell::new(None),
prev: Cell::new(None),
parent: Cell::new(None),
root: Cell::new(None),
prev_is_contiguous: Cell::new(false),
num_ancestors: Cell::new(0),
num_after: Cell::new(0),
Expand Down Expand Up @@ -271,10 +268,6 @@ impl<'a> Syntax<'a> {
self.info().parent.get()
}

pub fn root(&self) -> &'a Syntax<'a> {
self.info().root.get().unwrap()
}

pub fn next_sibling(&self) -> Option<&'a Syntax<'a>> {
self.info().next_sibling.get()
}
Expand Down Expand Up @@ -432,7 +425,6 @@ fn set_num_after(nodes: &[&Syntax], parent_num_after: usize) {
}
}
pub fn init_next_prev<'a>(roots: &[&'a Syntax<'a>]) {
set_root(roots);
set_prev_sibling(roots);
set_next_sibling(roots);
set_prev(roots, None);
Expand Down Expand Up @@ -536,24 +528,6 @@ fn set_parent<'a>(nodes: &[&'a Syntax<'a>], parent: Option<&'a Syntax<'a>>) {
}
}

fn set_root<'a>(nodes: &[&'a Syntax<'a>]) {
fn inner<'a>(nodes: &[&'a Syntax<'a>], root: &'a Syntax<'a>) {
for node in nodes {
node.info().root.set(Some(root));
if let List { children, .. } = node {
inner(children, root);
}
}
}

for node in nodes {
node.info().root.set(Some(node));
if let List { children, .. } = node {
inner(children, node);
}
}
}

fn set_num_ancestors(nodes: &[&Syntax], num_ancestors: u32) {
for node in nodes {
node.info().num_ancestors.set(num_ancestors);
Expand Down

0 comments on commit 1ede273

Please sign in to comment.