mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 05:08:52 +00:00
finer concurrency
This commit is contained in:
parent
1954df6336
commit
7264c3294b
3 changed files with 14 additions and 11 deletions
|
@ -12,6 +12,7 @@ unicode-xid = "0.1.0"
|
||||||
text_unit = "0.1.2"
|
text_unit = "0.1.2"
|
||||||
itertools = "0.7.5"
|
itertools = "0.7.5"
|
||||||
drop_bomb = "0.1.4"
|
drop_bomb = "0.1.4"
|
||||||
|
parking_lot = "0.6.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
testutils = { path = "./tests/testutils" }
|
testutils = { path = "./tests/testutils" }
|
||||||
|
|
|
@ -24,6 +24,7 @@ extern crate itertools;
|
||||||
extern crate text_unit;
|
extern crate text_unit;
|
||||||
extern crate unicode_xid;
|
extern crate unicode_xid;
|
||||||
extern crate drop_bomb;
|
extern crate drop_bomb;
|
||||||
|
extern crate parking_lot;
|
||||||
|
|
||||||
pub mod algo;
|
pub mod algo;
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::{ptr, sync::RwLock};
|
use std::ptr;
|
||||||
|
use parking_lot::RwLock;
|
||||||
use {yellow::GreenNode, TextUnit};
|
use {yellow::GreenNode, TextUnit};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -66,20 +67,20 @@ impl RedNode {
|
||||||
if idx >= self.n_children() {
|
if idx >= self.n_children() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
match &self.children.read().unwrap()[idx] {
|
match &self.children.read()[idx] {
|
||||||
Some(child) => return Some(child.into()),
|
Some(child) => return Some(child.into()),
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
let mut children = self.children.write().unwrap();
|
let green_children = self.green.children();
|
||||||
|
let start_offset = self.start_offset()
|
||||||
|
+ green_children[..idx]
|
||||||
|
.iter()
|
||||||
|
.map(|x| x.text_len())
|
||||||
|
.sum::<TextUnit>();
|
||||||
|
let child =
|
||||||
|
RedNode::new_child(green_children[idx].clone(), self.into(), start_offset, idx);
|
||||||
|
let mut children = self.children.write();
|
||||||
if children[idx].is_none() {
|
if children[idx].is_none() {
|
||||||
let green_children = self.green.children();
|
|
||||||
let start_offset = self.start_offset()
|
|
||||||
+ green_children[..idx]
|
|
||||||
.iter()
|
|
||||||
.map(|x| x.text_len())
|
|
||||||
.sum::<TextUnit>();
|
|
||||||
let child =
|
|
||||||
RedNode::new_child(green_children[idx].clone(), self.into(), start_offset, idx);
|
|
||||||
children[idx] = Some(child)
|
children[idx] = Some(child)
|
||||||
}
|
}
|
||||||
Some(children[idx].as_ref().unwrap().into())
|
Some(children[idx].as_ref().unwrap().into())
|
||||||
|
|
Loading…
Reference in a new issue