Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8e88d64
Added test for #49579.
davidtwco Jul 28, 2018
6d5694a
fix memrchr in miri
RalfJung Jul 30, 2018
d5f1f70
Fix Alias intra doc ICE
GuillaumeGomez Jul 29, 2018
f985e6c
tests/ui: Add missing mips{64} ignores
Jul 31, 2018
38e311e
Use SetLenOnDrop in Vec::truncate()
lnicola Jul 31, 2018
d94bdf8
Put back original field discovery
GuillaumeGomez Jul 31, 2018
84dc485
Allow borrow conflicts for promoted length 0 arrays
matthewjasper Jul 31, 2018
0babbf1
Don't count MIR locals as borrowed after StorageDead when finding loc…
Zoxc Jul 31, 2018
dbc0cd9
rustc_resolve: record single-segment extern crate import resolutions.
eddyb Aug 1, 2018
e462c06
Another SmallVec.extend optimization
llogiq Aug 1, 2018
b5ed39f
Implement custom read_to_end for io::Take
ljedrz Aug 1, 2018
1d64b24
Switch syntax attribute tracking to BitVector
Mark-Simulacrum Jul 30, 2018
9bc4fbb
Split out growth functionality into BitVector type
Mark-Simulacrum Jul 30, 2018
27b3cb5
rustc: Trim down the `rust_2018_idioms` lint group
alexcrichton Jul 31, 2018
c2d57db
1.27 actually added the `armv5te-unknown-linux-musleabi` target
Susurrus Aug 1, 2018
8bbf042
Added test for #49824.
davidtwco Jul 27, 2018
f685142
async can begin expressions
cramertj Aug 1, 2018
334da29
Rollup merge of #52793 - davidtwco:issue-49824, r=pnkfelix
pietroalbini Aug 1, 2018
42243f8
Rollup merge of #52799 - Mark-Simulacrum:attr-id-bitvecs, r=michaelwo…
pietroalbini Aug 1, 2018
4d1ddfe
Rollup merge of #52809 - davidtwco:issue-49579, r=pnkfelix
pietroalbini Aug 1, 2018
d5fcd27
Rollup merge of #52834 - matthewjasper:allow-zst-conflicts, r=pnkfelix
pietroalbini Aug 1, 2018
f52ef3b
Rollup merge of #52835 - GuillaumeGomez:ice-rustdoc-links, r=eddyb
pietroalbini Aug 1, 2018
e3928cc
Rollup merge of #52854 - RalfJung:memrchr, r=Kimundi
pietroalbini Aug 1, 2018
3ae03e9
Rollup merge of #52899 - draganmladjenovic:ui_tests64, r=alexcrichton
pietroalbini Aug 1, 2018
1997c70
Rollup merge of #52908 - lnicola:vec-truncate-opt, r=alexcrichton
pietroalbini Aug 1, 2018
b40b899
Rollup merge of #52915 - Zoxc:refine-gen-borrow-analysis, r=eddyb
pietroalbini Aug 1, 2018
110b71a
Rollup merge of #52926 - alexcrichton:trim-idioms-lints, r=oli-obk
pietroalbini Aug 1, 2018
2893bd0
Rollup merge of #52930 - eddyb:issue-52489, r=cramertj
pietroalbini Aug 1, 2018
eeb7b6a
Rollup merge of #52939 - ljedrz:fix_51746, r=kennytm
pietroalbini Aug 1, 2018
6e7e385
Rollup merge of #52942 - llogiq:smallvec-opt, r=Mark-Simulacrum
pietroalbini Aug 1, 2018
b2392fa
Rollup merge of #52947 - Susurrus:patch-1, r=alexcrichton
pietroalbini Aug 1, 2018
3e7897f
Rollup merge of #52954 - cramertj:async-parse, r=petrochenkov
pietroalbini Aug 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement custom read_to_end for io::Take
  • Loading branch information
ljedrz committed Aug 1, 2018
commit b5ed39ff10f0e46be6e97b577477e0f60234fa0b
19 changes: 16 additions & 3 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,19 +354,26 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
// avoid paying to allocate and zero a huge chunk of memory if the reader only
// has 4 bytes while still making large reads if the reader does have a ton
// of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every
// time is 4,500 times (!) slower than this if the reader has a very small
// amount of data to return.
// time is 4,500 times (!) slower than a default reservation size of 32 if the
// reader has a very small amount of data to return.
//
// Because we're extending the buffer with uninitialized data for trusted
// readers, we need to make sure to truncate that if any of this panics.
fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> {
read_to_end_with_reservation(r, buf, 32)
}

fn read_to_end_with_reservation<R: Read + ?Sized>(r: &mut R,
buf: &mut Vec<u8>,
reservation_size: usize) -> Result<usize>
{
let start_len = buf.len();
let mut g = Guard { len: buf.len(), buf: buf };
let ret;
loop {
if g.len == g.buf.len() {
unsafe {
g.buf.reserve(32);
g.buf.reserve(reservation_size);
let capacity = g.buf.capacity();
g.buf.set_len(capacity);
r.initializer().initialize(&mut g.buf[g.len..]);
Expand Down Expand Up @@ -1899,6 +1906,12 @@ impl<T: Read> Read for Take<T> {
unsafe fn initializer(&self) -> Initializer {
self.inner.initializer()
}

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
let reservation_size = cmp::min(self.limit, 32) as usize;

read_to_end_with_reservation(self, buf, reservation_size)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down