about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorUlrik Sverdrup <bluss@users.noreply.github.com>2015-07-08 22:52:55 +0200
committerUlrik Sverdrup <bluss@users.noreply.github.com>2015-07-09 11:05:32 +0200
commit836f32e7697195a482b88883cbbe4a2dd986d8cb (patch)
treef5855686978ec62f571011b78f1345a93ddd44e7 /src/libsyntax/ext
parent5b6a4643583c2b580b9a57f48dd94ba5d7824765 (diff)
downloadrust-836f32e7697195a482b88883cbbe4a2dd986d8cb.tar.gz
rust-836f32e7697195a482b88883cbbe4a2dd986d8cb.zip
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.)
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/format.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index 86e72d4ef03..5b972b464c9 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -23,7 +23,6 @@ use parse::token;
 use ptr::P;
 
 use std::collections::HashMap;
-use std::iter::repeat;
 
 #[derive(PartialEq)]
 enum ArgumentType {
@@ -469,7 +468,7 @@ impl<'a, 'b> Context<'a, 'b> {
     /// to
     fn into_expr(mut self) -> P<ast::Expr> {
         let mut locals = Vec::new();
-        let mut names: Vec<_> = repeat(None).take(self.name_positions.len()).collect();
+        let mut names = vec![None; self.name_positions.len()];
         let mut pats = Vec::new();
         let mut heads = Vec::new();