rustdoc: Reduce allocations in a theme
function
This commit is contained in:
parent
027a232755
commit
7feb7383d2
@ -173,15 +173,17 @@ fn build_rule(v: &[u8], positions: &[usize]) -> String {
|
|||||||
.map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or(""))
|
.map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or(""))
|
||||||
.collect::<String>()
|
.collect::<String>()
|
||||||
.trim()
|
.trim()
|
||||||
.replace('\n', " ")
|
.chars()
|
||||||
.replace('/', "")
|
.filter_map(|c| match c {
|
||||||
.replace('\t', " ")
|
'\n' | '\t' => Some(' '),
|
||||||
.replace('{', "")
|
'/' | '{' | '}' => None,
|
||||||
.replace('}', "")
|
c => Some(c),
|
||||||
|
})
|
||||||
|
.collect::<String>()
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.filter(|s| !s.is_empty())
|
.filter(|s| !s.is_empty())
|
||||||
.collect::<Vec<&str>>()
|
.intersperse(" ")
|
||||||
.join(" "),
|
.collect::<String>(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|_| String::new())
|
.unwrap_or_else(|_| String::new())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user