diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2015-07-08 22:52:55 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2015-07-09 11:05:32 +0200 |
| commit | 836f32e7697195a482b88883cbbe4a2dd986d8cb (patch) | |
| tree | f5855686978ec62f571011b78f1345a93ddd44e7 /src/librustc_data_structures | |
| parent | 5b6a4643583c2b580b9a57f48dd94ba5d7824765 (diff) | |
| download | rust-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/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/bitvec.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/librustc_data_structures/bitvec.rs b/src/librustc_data_structures/bitvec.rs index 983601771a0..f2f4a69d882 100644 --- a/src/librustc_data_structures/bitvec.rs +++ b/src/librustc_data_structures/bitvec.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::iter; - /// A very simple BitVector type. pub struct BitVector { data: Vec<u64> @@ -18,7 +16,7 @@ pub struct BitVector { impl BitVector { pub fn new(num_bits: usize) -> BitVector { let num_words = (num_bits + 63) / 64; - BitVector { data: iter::repeat(0).take(num_words).collect() } + BitVector { data: vec![0; num_words] } } fn word_mask(&self, bit: usize) -> (usize, u64) { |
