Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some optimizations (3) #401

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7cd3b10
Simplify push_{lhs,rhs}_delimiter
QuarticCat Sep 29, 2022
97f9a52
Remove field can_pop_either from Vertex
QuarticCat Sep 29, 2022
9f1a0ab
Reduce number of branches of Vertex::eq
QuarticCat Sep 29, 2022
d2f5e99
Compress &Syntax and SyntaxId into a usize
QuarticCat Sep 29, 2022
b635df4
Simplify get_set_neighbours using Default::default
QuarticCat Sep 29, 2022
69b9214
Simplify get_set_neighbours by extracting functions
QuarticCat Sep 30, 2022
827e26d
Eliminate some vec clones
QuarticCat Sep 30, 2022
1631eb2
Split predecessor to two parts
QuarticCat Sep 30, 2022
9c551ab
Change a RefCell in Vertex to UnsafeCell
QuarticCat Sep 30, 2022
7d36c5f
Refactor seen map
QuarticCat Sep 30, 2022
2293886
Minor fixes
QuarticCat Sep 30, 2022
2c6b706
Refactor parents representation
QuarticCat Sep 30, 2022
cb1c3e0
Compress EnteredDelimiter
QuarticCat Sep 30, 2022
4e450cb
Simplify set_neighbours by extracting a lambda
QuarticCat Sep 30, 2022
b0ab6c8
Reserve vec capacity
QuarticCat Sep 30, 2022
5043858
Remove transmute_copy
QuarticCat Sep 30, 2022
8327c99
Compress seen map
QuarticCat Sep 30, 2022
3612d08
Skip visited vertices
QuarticCat Sep 30, 2022
9e11a22
Refactor shortest path algorithm
QuarticCat Sep 30, 2022
a47000f
Skip visited vertices when searching neighbors
QuarticCat Oct 1, 2022
88ba693
Simplify code
QuarticCat Oct 1, 2022
5e5eef2
Compress stack to bitmap
QuarticCat Oct 1, 2022
ec52830
Add comments
QuarticCat Oct 1, 2022
ee725a1
Add asserts
QuarticCat Oct 2, 2022
8a0c82a
Reuse neighbors vector
QuarticCat Oct 2, 2022
0e9a4c2
Add root to SyntaxInfo to optimize parent comparison
QuarticCat Oct 2, 2022
63eadc1
Optimize can_pop_either
QuarticCat Oct 2, 2022
82ce472
Update assert text
QuarticCat Oct 2, 2022
8625f62
Reserve change_map space
QuarticCat Oct 2, 2022
d921c75
Combine insert_deep_unchanged calls
QuarticCat Oct 2, 2022
97e883d
Reserve arena space
QuarticCat Oct 2, 2022
7e4e747
Refactor BitStack
QuarticCat Oct 2, 2022
ec56c99
Small tweaks
QuarticCat Oct 2, 2022
005a5a6
Fix a bug
QuarticCat Oct 5, 2022
10ce859
Reduce edge kinds
QuarticCat Oct 6, 2022
efc70f5
Combine some ExitDelimiterLHS/RHS vertices
QuarticCat Oct 6, 2022
e2bf31f
Simplify get_neighbours
QuarticCat Oct 6, 2022
4f01c1e
Combine all ExitDelimiterLHS/RHS vertices
QuarticCat Oct 7, 2022
fef1454
Simplify get_neighbours
QuarticCat Oct 7, 2022
edc5516
Completely remove ExitDelimiter vertices
QuarticCat Oct 7, 2022
adf6077
Add more #[inline(always)]
QuarticCat Oct 7, 2022
1ede273
Remove root field from SyntaxInfo
QuarticCat Oct 11, 2022
bc09acc
Fix typo
QuarticCat Nov 12, 2022
b95c3a6
Refactor parent stack
QuarticCat Nov 12, 2022
153502e
Optimize from_parent
QuarticCat Nov 13, 2022
cea109e
Use insert_unique_unchecked
QuarticCat Nov 13, 2022
0eb70c8
Fix arena reservation
QuarticCat Nov 20, 2022
a0c3293
Reduce branches of get_neighbours
QuarticCat Nov 21, 2022
afe07ea
Pre-compute edge cost to reduce the size of Vertex
QuarticCat Nov 21, 2022
d7d1653
Merge similar code logic
QuarticCat Nov 21, 2022
96a779c
Simplify code
QuarticCat Nov 21, 2022
864fecf
Optimize parent_stack_eq
QuarticCat Nov 21, 2022
8845aab
Optimize next_vertex
QuarticCat Nov 21, 2022
63c2830
Make SideSyntax conform to strict provenance
QuarticCat Nov 21, 2022
eb16d57
Further squeeze Vertex
QuarticCat Nov 21, 2022
88d5cee
Fine tune next_sibling & next_child
QuarticCat Nov 21, 2022
5167d30
Simplify next_vertex
QuarticCat Nov 21, 2022
80eae29
Fix comment
QuarticCat Nov 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ clap = { version = "3.1.8", features = ["cargo", "env", "wrap_help"] }
itertools = "0.10.1"
typed-arena = "2.0.1"
rustc-hash = "1.1.0"
hashbrown = "0.12.3"
strsim = "0.10.0"
lazy_static = "1.4.0"
atty = "0.2.14"
Expand Down
19 changes: 12 additions & 7 deletions src/diff/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,32 @@ impl<'a> ChangeMap<'a> {
pub fn get(&self, node: &Syntax<'a>) -> Option<ChangeKind<'a>> {
self.changes.get(&node.id()).copied()
}

pub fn reserve(&mut self, additional: usize) {
self.changes.reserve(additional);
}
}

pub fn insert_deep_unchanged<'a>(
node: &'a Syntax<'a>,
opposite_node: &'a Syntax<'a>,
lhs: &'a Syntax<'a>,
rhs: &'a Syntax<'a>,
change_map: &mut ChangeMap<'a>,
) {
change_map.insert(node, ChangeKind::Unchanged(opposite_node));
change_map.insert(lhs, ChangeKind::Unchanged(rhs));
change_map.insert(rhs, ChangeKind::Unchanged(lhs));

match (node, opposite_node) {
match (lhs, rhs) {
(
Syntax::List {
children: node_children,
children: lhs_children,
..
},
Syntax::List {
children: opposite_children,
children: rhs_children,
..
},
) => {
for (child, opposite_child) in node_children.iter().zip(opposite_children) {
for (child, opposite_child) in lhs_children.iter().zip(rhs_children) {
insert_deep_unchanged(child, opposite_child, change_map);
}
}
Expand Down
Loading