aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_prof/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-26 17:02:00 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-26 17:02:00 +0100
commit1dd3d9bc2d328e164c594f3d2022dcf174f907a9 (patch)
treee4d7f73b0253fb882ac043dd75a111fcaf487c27 /crates/ra_prof/src
parent42c4e0f378faeabd425392d4a7a7839bd7e8ac2f (diff)
parentd8649c1af86118dea6b6340c999b5864a8d55279 (diff)
Merge #1212
1212: Clippy cleanups r=matklad a=kjeremy Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates/ra_prof/src')
-rw-r--r--crates/ra_prof/src/lib.rs17
1 files changed, 7 insertions, 10 deletions
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