Skip to content

Commit

Permalink
Add more #[inline(always)]
Browse files Browse the repository at this point in the history
  • Loading branch information
QuarticCat committed Oct 7, 2022
1 parent edc5516 commit adf6077
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/diff/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::{
diff::changes::{insert_deep_unchanged, ChangeKind, ChangeMap},
parse::syntax::{AtomKind, Syntax},
};
use Edge::*;

/// Compress two `&Syntax` into a usize.
///
Expand Down Expand Up @@ -82,17 +81,6 @@ impl<'a> SideSyntax<'a> {
}
}

fn next_sibling<'a>(syntax: &'a Syntax<'a>) -> SideSyntax<'a> {
let parent = SideSyntax::from_parent(syntax.parent());
syntax.next_sibling().map_or(parent, SideSyntax::from_side)
}

fn next_child<'a>(syntax: &'a Syntax<'a>, children: &[&'a Syntax<'a>]) -> SideSyntax<'a> {
let parent = SideSyntax::from_parent(Some(syntax));
let child = children.get(0).copied();
child.map_or(parent, SideSyntax::from_side)
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u64)]
enum EnteredDelimiter {
Expand Down Expand Up @@ -317,6 +305,8 @@ pub enum Edge {
},
}

use Edge::*;

const NOT_CONTIGUOUS_PENALTY: u64 = 50;

impl Edge {
Expand Down Expand Up @@ -409,6 +399,19 @@ fn looks_like_punctuation(content: &str) -> bool {
content == "," || content == ";" || content == "."
}

#[inline(always)]
fn next_sibling<'a>(syntax: &'a Syntax<'a>) -> SideSyntax<'a> {
let parent = SideSyntax::from_parent(syntax.parent());
syntax.next_sibling().map_or(parent, SideSyntax::from_side)
}

#[inline(always)]
fn next_child<'a>(syntax: &'a Syntax<'a>, children: &[&'a Syntax<'a>]) -> SideSyntax<'a> {
let parent = SideSyntax::from_parent(Some(syntax));
let child = children.get(0).copied();
child.map_or(parent, SideSyntax::from_side)
}

#[inline(always)]
fn next_vertex<'a, 'b>(
mut lhs_syntax: SideSyntax<'a>,
Expand Down

0 comments on commit adf6077

Please sign in to comment.