1
Fork 0

Use vec![elt; n] where possible

The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is
exactly equivalent to `vec![elt; n]`, do this replacement in the whole
tree.

(Actually, vec![] is smart enough to only call clone n - 1 times, while
the former solution would call clone n times, and this fact is
virtually irrelevant in practice.)
This commit is contained in:
Ulrik Sverdrup 2015-07-08 22:52:55 +02:00
parent 5b6a464358
commit 836f32e769
31 changed files with 61 additions and 91 deletions

View file

@ -1920,7 +1920,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
try!(write!(w, r#"<script type="text/javascript" async
src="{root_path}/implementors/{path}/{ty}.{name}.js">
</script>"#,
root_path = repeat("..").take(cx.current.len()).collect::<Vec<_>>().connect("/"),
root_path = vec![".."; cx.current.len()].connect("/"),
path = if ast_util::is_local(it.def_id) {
cx.current.connect("/")
} else {