aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_arena/src/lib.rs5
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs12
-rw-r--r--crates/ra_prof/src/lib.rs17
3 files changed, 17 insertions, 17 deletions
diff --git a/crates/ra_arena/src/lib.rs b/crates/ra_arena/src/lib.rs
index 1c97c2662..26641e690 100644
--- a/crates/ra_arena/src/lib.rs
+++ b/crates/ra_arena/src/lib.rs
@@ -71,12 +71,15 @@ impl<ID: ArenaId, T> Arena<ID, T> {
71 pub fn len(&self) -> usize { 71 pub fn len(&self) -> usize {
72 self.data.len() 72 self.data.len()
73 } 73 }
74 pub fn is_empty(&self) -> bool {
75 self.data.is_empty()
76 }
74 pub fn alloc(&mut self, value: T) -> ID { 77 pub fn alloc(&mut self, value: T) -> ID {
75 let id = RawId(self.data.len() as u32); 78 let id = RawId(self.data.len() as u32);
76 self.data.push(value); 79 self.data.push(value);
77 ID::from_raw(id) 80 ID::from_raw(id)
78 } 81 }
79 pub fn iter<'a>(&'a self) -> impl Iterator<Item = (ID, &'a T)> { 82 pub fn iter(&self) -> impl Iterator<Item = (ID, &T)> {
80 self.data.iter().enumerate().map(|(idx, value)| (ID::from_raw(RawId(idx as u32)), value)) 83 self.data.iter().enumerate().map(|(idx, value)| (ID::from_raw(RawId(idx as u32)), value))
81 } 84 }
82} 85}
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 8df9035e9..9fe529f53 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -252,12 +252,12 @@ fn expr_bp(
252 // `newly_dollar_open` is a flag indicated that dollar is just closed after lhs, e.g. 252 // `newly_dollar_open` is a flag indicated that dollar is just closed after lhs, e.g.
253 // `$1$ + a` 253 // `$1$ + a`
254 // We use this flag to skip handling it. 254 // We use this flag to skip handling it.
255 let mut newly_dollar_open = false; 255 let mut newly_dollar_open = if p.at_l_dollar() {
256
257 if p.at_l_dollar() {
258 *dollar_lvl += p.eat_l_dollars(); 256 *dollar_lvl += p.eat_l_dollars();
259 newly_dollar_open = true; 257 true
260 } 258 } else {
259 false
260 };
261 261
262 let mut lhs = match lhs(p, r, dollar_lvl) { 262 let mut lhs = match lhs(p, r, dollar_lvl) {
263 Some((lhs, blocklike)) => { 263 Some((lhs, blocklike)) => {
@@ -535,7 +535,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
535 } 535 }
536 EXCL => { 536 EXCL => {
537 let block_like = items::macro_call_after_excl(p); 537 let block_like = items::macro_call_after_excl(p);
538 return (m.complete(p, MACRO_CALL), block_like); 538 (m.complete(p, MACRO_CALL), block_like)
539 } 539 }
540 _ => (m.complete(p, PATH_EXPR), BlockLike::NotBlock), 540 _ => (m.complete(p, PATH_EXPR), BlockLike::NotBlock),
541 } 541 }
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index 402c719b1..9ecb8e744 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -67,14 +67,11 @@ pub fn profile(desc: &str) -> Profiler {
67 67
68 PROFILE_STACK.with(|stack| { 68 PROFILE_STACK.with(|stack| {
69 let mut stack = stack.borrow_mut(); 69 let mut stack = stack.borrow_mut();
70 if stack.starts.len() == 0 { 70 if stack.starts.is_empty() {
71 match FILTER.try_read() { 71 if let Ok(f) = FILTER.try_read() {
72 Ok(f) => { 72 if f.version > stack.filter_data.version {
73 if f.version > stack.filter_data.version { 73 stack.filter_data = f.clone();
74 stack.filter_data = f.clone();
75 }
76 } 74 }
77 Err(_) => (),
78 }; 75 };
79 } 76 }
80 77
@@ -107,7 +104,7 @@ impl Filter {
107 // env RA_PROFILE=foo|bar|baz // enabled only selected entries 104 // env RA_PROFILE=foo|bar|baz // enabled only selected entries
108 // env RA_PROFILE=*@3>10 // dump everything, up to depth 3, if it takes more than 10 ms 105 // env RA_PROFILE=*@3>10 // dump everything, up to depth 3, if it takes more than 10 ms
109 pub fn from_spec(mut spec: &str) -> Filter { 106 pub fn from_spec(mut spec: &str) -> Filter {
110 let longer_than = if let Some(idx) = spec.rfind(">") { 107 let longer_than = if let Some(idx) = spec.rfind('>') {
111 let longer_than = spec[idx + 1..].parse().expect("invalid profile longer_than"); 108 let longer_than = spec[idx + 1..].parse().expect("invalid profile longer_than");
112 spec = &spec[..idx]; 109 spec = &spec[..idx];
113 Duration::from_millis(longer_than) 110 Duration::from_millis(longer_than)
@@ -115,7 +112,7 @@ impl Filter {
115 Duration::new(0, 0) 112 Duration::new(0, 0)
116 }; 113 };
117 114
118 let depth = if let Some(idx) = spec.rfind("@") { 115 let depth = if let Some(idx) = spec.rfind('@') {
119 let depth: usize = spec[idx + 1..].parse().expect("invalid profile depth"); 116 let depth: usize = spec[idx + 1..].parse().expect("invalid profile depth");
120 spec = &spec[..idx]; 117 spec = &spec[..idx];
121 depth 118 depth
@@ -123,7 +120,7 @@ impl Filter {
123 999 120 999
124 }; 121 };
125 let allowed = 122 let allowed =
126 if spec == "*" { Vec::new() } else { spec.split("|").map(String::from).collect() }; 123 if spec == "*" { Vec::new() } else { spec.split('|').map(String::from).collect() };
127 Filter::new(depth, allowed, longer_than) 124 Filter::new(depth, allowed, longer_than)
128 } 125 }
129 126