From 47f10fce8ada7638e3298e3e12f794b4859af754 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Fri, 26 Apr 2019 11:41:58 -0400 Subject: Pass in char instead of single-char string --- crates/ra_prof/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_prof/src') diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index 402c719b1..ba432912f 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs @@ -107,7 +107,7 @@ impl Filter { // env RA_PROFILE=foo|bar|baz // enabled only selected entries // env RA_PROFILE=*@3>10 // dump everything, up to depth 3, if it takes more than 10 ms pub fn from_spec(mut spec: &str) -> Filter { - let longer_than = if let Some(idx) = spec.rfind(">") { + let longer_than = if let Some(idx) = spec.rfind('>') { let longer_than = spec[idx + 1..].parse().expect("invalid profile longer_than"); spec = &spec[..idx]; Duration::from_millis(longer_than) @@ -115,7 +115,7 @@ impl Filter { Duration::new(0, 0) }; - let depth = if let Some(idx) = spec.rfind("@") { + let depth = if let Some(idx) = spec.rfind('@') { let depth: usize = spec[idx + 1..].parse().expect("invalid profile depth"); spec = &spec[..idx]; depth @@ -123,7 +123,7 @@ impl Filter { 999 }; let allowed = - if spec == "*" { Vec::new() } else { spec.split("|").map(String::from).collect() }; + if spec == "*" { Vec::new() } else { spec.split('|').map(String::from).collect() }; Filter::new(depth, allowed, longer_than) } -- cgit v1.2.3 From d8649c1af86118dea6b6340c999b5864a8d55279 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Fri, 26 Apr 2019 11:42:56 -0400 Subject: Simplify --- crates/ra_prof/src/lib.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'crates/ra_prof/src') diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index ba432912f..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 { PROFILE_STACK.with(|stack| { let mut stack = stack.borrow_mut(); - if stack.starts.len() == 0 { - match FILTER.try_read() { - Ok(f) => { - if f.version > stack.filter_data.version { - stack.filter_data = f.clone(); - } + if stack.starts.is_empty() { + if let Ok(f) = FILTER.try_read() { + if f.version > stack.filter_data.version { + stack.filter_data = f.clone(); } - Err(_) => (), }; } -- cgit v1.2.3