Refactor option handling
This commit is contained in:
parent
ffe57fad85
commit
3fc1ec1ffd
9 changed files with 19 additions and 55 deletions
|
|
@ -196,14 +196,8 @@ impl<'a, 'tcx> Functions {
|
|||
let mut code_in_line;
|
||||
|
||||
// Skip the surrounding function decl.
|
||||
let start_brace_idx = match code_snippet.find('{') {
|
||||
Some(i) => i + 1,
|
||||
None => 0,
|
||||
};
|
||||
let end_brace_idx = match code_snippet.rfind('}') {
|
||||
Some(i) => i,
|
||||
None => code_snippet.len(),
|
||||
};
|
||||
let start_brace_idx = code_snippet.find('{').map_or(0, |i| i + 1);
|
||||
let end_brace_idx = code_snippet.rfind('}').unwrap_or_else(|| code_snippet.len());
|
||||
let function_lines = code_snippet[start_brace_idx..end_brace_idx].lines();
|
||||
|
||||
for mut line in function_lines {
|
||||
|
|
@ -223,14 +217,8 @@ impl<'a, 'tcx> Functions {
|
|||
None => break,
|
||||
}
|
||||
} else {
|
||||
let multi_idx = match line.find("/*") {
|
||||
Some(i) => i,
|
||||
None => line.len(),
|
||||
};
|
||||
let single_idx = match line.find("//") {
|
||||
Some(i) => i,
|
||||
None => line.len(),
|
||||
};
|
||||
let multi_idx = line.find("/*").unwrap_or_else(|| line.len());
|
||||
let single_idx = line.find("//").unwrap_or_else(|| line.len());
|
||||
code_in_line |= multi_idx > 0 && single_idx > 0;
|
||||
// Implies multi_idx is below line.len()
|
||||
if multi_idx < single_idx {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue