diff options
| author | bors <bors@rust-lang.org> | 2015-07-09 10:36:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-07-09 10:36:41 +0000 |
| commit | f11502cda8a05aae9b260141ac9c4538d46bb01b (patch) | |
| tree | fd3a72c4bf63d6d12a48155843dd172af01a6a70 /src/libcollections | |
| parent | 517e087c16749086a3a0fec453af3d1c53232605 (diff) | |
| parent | 836f32e7697195a482b88883cbbe4a2dd986d8cb (diff) | |
| download | rust-f11502cda8a05aae9b260141ac9c4538d46bb01b.tar.gz rust-f11502cda8a05aae9b260141ac9c4538d46bb01b.zip | |
Auto merge of #26904 - bluss:no-repeat, r=alexcrichton
In a followup to PR #26849, improve one more location for I/O where we can use `Vec::resize` to ensure better performance when zeroing buffers. Use the `vec![elt; n]` macro everywhere we can in the tree. It replaces `repeat(elt).take(n).collect()` which is more verbose, requires type hints, and right now produces worse code. `vec![]` is preferable for vector initialization. The `vec![]` replacement touches upon one I/O path too, Stdin::read for windows, and that should be a small improvement. r? @alexcrichton
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/bit.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index a8d638028be..3a4cfbba65f 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -283,7 +283,7 @@ impl BitVec { pub fn from_elem(nbits: usize, bit: bool) -> BitVec { let nblocks = blocks_for_bits(nbits); let mut bit_vec = BitVec { - storage: repeat(if bit { !0 } else { 0 }).take(nblocks).collect(), + storage: vec![if bit { !0 } else { 0 }; nblocks], nbits: nbits }; bit_vec.fix_last_block(); |
