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/libstd/sys/windows | |
| 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/libstd/sys/windows')
| -rw-r--r-- | src/libstd/sys/windows/stdio.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs index 9961fef714a..356787d5bf0 100644 --- a/src/libstd/sys/windows/stdio.rs +++ b/src/libstd/sys/windows/stdio.rs @@ -12,7 +12,6 @@ use prelude::v1::*; use io::prelude::*; use io::{self, Cursor}; -use iter::repeat; use libc; use ptr; use str; @@ -94,7 +93,7 @@ impl Stdin { let mut utf8 = self.utf8.lock().unwrap(); // Read more if the buffer is empty if utf8.position() as usize == utf8.get_ref().len() { - let mut utf16: Vec<u16> = repeat(0u16).take(0x1000).collect(); + let mut utf16 = vec![0u16; 0x1000]; let mut num = 0; try!(cvt(unsafe { c::ReadConsoleW(handle, |
