Skip to content

Commit ead1b82

Browse files
committed
---
yaml --- r: 195287 b: refs/heads/tmp c: f55d03c h: refs/heads/master i: 195285: 017bfff 195283: 6c003a7 195279: e4e1e98 v: v3
1 parent d46c600 commit ead1b82

File tree

27 files changed

+105
-84
lines changed

27 files changed

+105
-84
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: d8be84eb4499e21bd98a3500c8760540996df23b
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: f575acaf5ff4aa0abf402d0ad758e722ebd31df4
37+
refs/heads/tmp: f55d03c8d8f5cf76628da771c1f5c4b9a9589c00
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3939
refs/tags/homu-tmp: 53a183f0274316596bf9405944d4f0468d8c93e4
4040
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ case $CFG_OSTYPE in
404404
CFG_OSTYPE=pc-windows-gnu
405405
;;
406406

407-
# Thad's Cygwin identifers below
407+
# Thad's Cygwin identifiers below
408408

409409
# Vista 32 bit
410410
CYGWIN_NT-6.0)

branches/tmp/mk/platform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ define CFG_MAKE_TOOLCHAIN
179179

180180
ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),)
181181

182-
# On Bitrig, we need the relocation model to be PIC for everthing
182+
# On Bitrig, we need the relocation model to be PIC for everything
183183
ifeq (,$(filter $(OSTYPE_$(1)),bitrig))
184184
LLVM_MC_RELOCATION_MODEL="pic"
185185
else

branches/tmp/mk/target.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ endef
132132
# on $$(TSREQ$(1)_T_$(2)_H_$(3)), to ensure that no products will be
133133
# put into the target area until after the get-snapshot.py script has
134134
# had its chance to clean it out; otherwise the other products will be
135-
# inadvertantly included in the clean out.
135+
# inadvertently included in the clean out.
136136
SNAPSHOT_RUSTC_POST_CLEANUP=$(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD))
137137

138138
define TARGET_HOST_RULES

branches/tmp/src/doc/trpl/associated-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ let obj = Box::new(graph) as Box<Graph>;
170170
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171171
```
172172

173-
We can’t create a trait object like this, becuase we don’t know the associated
173+
We can’t create a trait object like this, because we don’t know the associated
174174
types. Instead, we can write this:
175175

176176
```rust

branches/tmp/src/doc/trpl/documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ This will create documentation for bar both inside the documentation for the
529529
crate `foo`, as well as the documentation for your crate. It will use the same
530530
documentation in both places.
531531

532-
This behavior can be supressed with `no_inline`:
532+
This behavior can be suppressed with `no_inline`:
533533

534534
```ignore
535535
extern crate foo;

branches/tmp/src/etc/rustup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ case $CFG_OSTYPE in
335335
MINGW32*)
336336
CFG_OSTYPE=pc-mingw32
337337
;;
338-
# Thad's Cygwin identifers below
338+
# Thad's Cygwin identifiers below
339339

340340
# Vista 32 bit
341341
CYGWIN_NT-6.0)
@@ -437,7 +437,7 @@ CFG_TMP_DIR=$(mktemp -d 2>/dev/null \
437437
|| create_tmp_dir)
438438

439439
# If we're saving nightlies and we didn't specify which one, grab the latest
440-
# verison from the perspective of the server. Buildbot has typically finished
440+
# version from the perspective of the server. Buildbot has typically finished
441441
# building and uploading by ~8UTC, but we want to include a little buffer.
442442
#
443443
# FIXME It would be better to use the known most recent nightly that has been

branches/tmp/src/libcore/marker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ pub struct InvariantType<T>;
476476
/// particular, thanks to the `Reflect` bound, callers know that a
477477
/// function declared like `fn bar<T>(...)` will always act in
478478
/// precisely the same way no matter what type `T` is supplied,
479-
/// beacuse there are no bounds declared on `T`. (The ability for a
479+
/// because there are no bounds declared on `T`. (The ability for a
480480
/// caller to reason about what a function may do based solely on what
481481
/// generic bounds are declared is often called the ["parametricity
482482
/// property"][1].)

branches/tmp/src/librbml/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
//! - `Sub32` (`0d`): 4-byte unsigned integer for supplementary information.
8484
//! Those two tags normally occur as the first subdocument of certain tags,
8585
//! namely `Enum`, `Vec` and `Map`, to provide a variant or size information.
86-
//! They can be used interchangably.
86+
//! They can be used interchangeably.
8787
//!
8888
//! Predefined tags with an explicit length:
8989
//!

branches/tmp/src/librustc_back/target/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub struct TargetOptions {
157157
/// particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false.
158158
pub is_like_osx: bool,
159159
/// Whether the target toolchain is like Windows'. Only useful for compiling against Windows,
160-
/// only realy used for figuring out how to find libraries, since Windows uses its own
160+
/// only really used for figuring out how to find libraries, since Windows uses its own
161161
/// library naming convention. Defaults to false.
162162
pub is_like_windows: bool,
163163
/// Whether the target toolchain is like Android's. Only useful for compiling against Android.

branches/tmp/src/librustdoc/html/static/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,10 @@ h1 .stability {
493493
.stability.Locked { border-color: #0084B6; color: #00668c; }
494494
.stability.Unmarked { border-color: #BBBBBB; }
495495

496+
td.summary-column {
497+
width: 100%;
498+
}
499+
496500
.summary {
497501
padding-right: 0px;
498502
}

branches/tmp/src/librustdoc/stability_summary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Ord for ModuleSummary {
8686
}
8787
}
8888

89-
// is the item considered publically visible?
89+
// is the item considered publicly visible?
9090
fn visible(item: &Item) -> bool {
9191
match item.inner {
9292
ImplItem(_) => true,

branches/tmp/src/libstd/fs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ mod tests {
15111511
assert_eq!(v, b"foobar\0\0\0\0".to_vec());
15121512

15131513
// Truncate to a smaller length, don't seek, and then write something.
1514-
// Ensure that the intermediate zeroes are all filled in (we're seeked
1514+
// Ensure that the intermediate zeroes are all filled in (we have `seek`ed
15151515
// past the end of the file).
15161516
check!(file.set_len(2));
15171517
assert_eq!(check!(file.metadata()).len(), 2);

branches/tmp/src/libstd/io/buffered.rs

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ use io::prelude::*;
1818
use cmp;
1919
use error::{self, FromError};
2020
use fmt;
21-
use io::{self, Cursor, DEFAULT_BUF_SIZE, Error, ErrorKind};
21+
use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind};
2222
use ptr;
23+
use iter;
2324

2425
/// Wraps a `Read` and buffers input from it
2526
///
@@ -30,7 +31,9 @@ use ptr;
3031
#[stable(feature = "rust1", since = "1.0.0")]
3132
pub struct BufReader<R> {
3233
inner: R,
33-
buf: Cursor<Vec<u8>>,
34+
buf: Vec<u8>,
35+
pos: usize,
36+
cap: usize,
3437
}
3538

3639
impl<R: Read> BufReader<R> {
@@ -43,9 +46,13 @@ impl<R: Read> BufReader<R> {
4346
/// Creates a new `BufReader` with the specified buffer capacity
4447
#[stable(feature = "rust1", since = "1.0.0")]
4548
pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
49+
let mut buf = Vec::with_capacity(cap);
50+
buf.extend(iter::repeat(0).take(cap));
4651
BufReader {
4752
inner: inner,
48-
buf: Cursor::new(Vec::with_capacity(cap)),
53+
buf: buf,
54+
pos: 0,
55+
cap: 0,
4956
}
5057
}
5158

@@ -74,12 +81,15 @@ impl<R: Read> Read for BufReader<R> {
7481
// If we don't have any buffered data and we're doing a massive read
7582
// (larger than our internal buffer), bypass our internal buffer
7683
// entirely.
77-
if self.buf.get_ref().len() == self.buf.position() as usize &&
78-
buf.len() >= self.buf.get_ref().capacity() {
84+
if self.pos == self.cap && buf.len() >= self.buf.len() {
7985
return self.inner.read(buf);
8086
}
81-
try!(self.fill_buf());
82-
self.buf.read(buf)
87+
let nread = {
88+
let mut rem = try!(self.fill_buf());
89+
try!(rem.read(buf))
90+
};
91+
self.consume(nread);
92+
Ok(nread)
8393
}
8494
}
8595

@@ -88,26 +98,25 @@ impl<R: Read> BufRead for BufReader<R> {
8898
fn fill_buf(&mut self) -> io::Result<&[u8]> {
8999
// If we've reached the end of our internal buffer then we need to fetch
90100
// some more data from the underlying reader.
91-
if self.buf.position() as usize == self.buf.get_ref().len() {
92-
self.buf.set_position(0);
93-
let v = self.buf.get_mut();
94-
v.truncate(0);
95-
let inner = &mut self.inner;
96-
try!(super::with_end_to_cap(v, |b| inner.read(b)));
101+
if self.pos == self.cap {
102+
self.cap = try!(self.inner.read(&mut self.buf));
103+
self.pos = 0;
97104
}
98-
self.buf.fill_buf()
105+
Ok(&self.buf[self.pos..self.cap])
99106
}
100107

101108
fn consume(&mut self, amt: usize) {
102-
self.buf.consume(amt)
109+
self.pos = cmp::min(self.pos + amt, self.cap);
103110
}
104111
}
105112

106113
#[stable(feature = "rust1", since = "1.0.0")]
107114
impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug {
108115
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
109-
write!(fmt, "BufReader {{ reader: {:?}, buffer: {}/{} }}",
110-
self.inner, self.buf.position(), self.buf.get_ref().len())
116+
fmt.debug_struct("BufReader")
117+
.field("reader", &self.inner)
118+
.field("buffer", &format_args!("{}/{}", self.cap - self.pos, self.buf.len()))
119+
.finish()
111120
}
112121
}
113122

@@ -222,8 +231,10 @@ impl<W: Write> Write for BufWriter<W> {
222231
#[stable(feature = "rust1", since = "1.0.0")]
223232
impl<W: Write> fmt::Debug for BufWriter<W> where W: fmt::Debug {
224233
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
225-
write!(fmt, "BufWriter {{ writer: {:?}, buffer: {}/{} }}",
226-
self.inner.as_ref().unwrap(), self.buf.len(), self.buf.capacity())
234+
fmt.debug_struct("BufWriter")
235+
.field("writer", &self.inner.as_ref().unwrap())
236+
.field("buffer", &format_args!("{}/{}", self.buf.len(), self.buf.capacity()))
237+
.finish()
227238
}
228239
}
229240

@@ -337,9 +348,11 @@ impl<W: Write> Write for LineWriter<W> {
337348
#[stable(feature = "rust1", since = "1.0.0")]
338349
impl<W: Write> fmt::Debug for LineWriter<W> where W: fmt::Debug {
339350
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
340-
write!(fmt, "LineWriter {{ writer: {:?}, buffer: {}/{} }}",
341-
self.inner.inner, self.inner.buf.len(),
342-
self.inner.buf.capacity())
351+
fmt.debug_struct("LineWriter")
352+
.field("writer", &self.inner.inner)
353+
.field("buffer",
354+
&format_args!("{}/{}", self.inner.buf.len(), self.inner.buf.capacity()))
355+
.finish()
343356
}
344357
}
345358

@@ -415,10 +428,10 @@ impl<S: Read + Write> BufStream<S> {
415428
/// Any leftover data in the read buffer is lost.
416429
#[stable(feature = "rust1", since = "1.0.0")]
417430
pub fn into_inner(self) -> Result<S, IntoInnerError<BufStream<S>>> {
418-
let BufReader { inner: InternalBufWriter(w), buf } = self.inner;
431+
let BufReader { inner: InternalBufWriter(w), buf, pos, cap } = self.inner;
419432
w.into_inner().map_err(|IntoInnerError(w, e)| {
420433
IntoInnerError(BufStream {
421-
inner: BufReader { inner: InternalBufWriter(w), buf: buf },
434+
inner: BufReader { inner: InternalBufWriter(w), buf: buf, pos: pos, cap: cap },
422435
}, e)
423436
})
424437
}
@@ -452,10 +465,12 @@ impl<S: Write> fmt::Debug for BufStream<S> where S: fmt::Debug {
452465
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
453466
let reader = &self.inner;
454467
let writer = &self.inner.inner.0;
455-
write!(fmt, "BufStream {{ stream: {:?}, write_buffer: {}/{}, read_buffer: {}/{} }}",
456-
writer.inner,
457-
writer.buf.len(), writer.buf.capacity(),
458-
reader.buf.position(), reader.buf.get_ref().len())
468+
fmt.debug_struct("BufStream")
469+
.field("stream", &writer.inner)
470+
.field("write_buffer", &format_args!("{}/{}", writer.buf.len(), writer.buf.capacity()))
471+
.field("read_buffer",
472+
&format_args!("{}/{}", reader.cap - reader.pos, reader.buf.len()))
473+
.finish()
459474
}
460475
}
461476

branches/tmp/src/libstd/io/mod.rs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,6 @@ mod stdio;
4848

4949
const DEFAULT_BUF_SIZE: usize = 64 * 1024;
5050

51-
// Acquires a slice of the vector `v` from its length to its capacity
52-
// (after initializing the data), reads into it, and then updates the length.
53-
//
54-
// This function is leveraged to efficiently read some bytes into a destination
55-
// vector without extra copying and taking advantage of the space that's already
56-
// in `v`.
57-
fn with_end_to_cap<F>(v: &mut Vec<u8>, f: F) -> Result<usize>
58-
where F: FnOnce(&mut [u8]) -> Result<usize>
59-
{
60-
let len = v.len();
61-
let new_area = v.capacity() - len;
62-
v.extend(iter::repeat(0).take(new_area));
63-
match f(&mut v[len..]) {
64-
Ok(n) => {
65-
v.truncate(len + n);
66-
Ok(n)
67-
}
68-
Err(e) => {
69-
v.truncate(len);
70-
Err(e)
71-
}
72-
}
73-
}
74-
7551
// A few methods below (read_to_string, read_line) will append data into a
7652
// `String` buffer, but we need to be pretty careful when doing this. The
7753
// implementation will just call `.as_mut_vec()` and then delegate to a
@@ -116,19 +92,45 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
11692
}
11793
}
11894

95+
// This uses an adaptive system to extend the vector when it fills. We want to
96+
// avoid paying to allocate and zero a huge chunk of memory if the reader only
97+
// has 4 bytes while still making large reads if the reader does have a ton
98+
// of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every
99+
// time is 4,500 times (!) slower than this if the reader has a very small
100+
// amount of data to return.
119101
fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> {
120-
let mut read = 0;
102+
let start_len = buf.len();
103+
let mut len = start_len;
104+
let mut cap_bump = 16;
105+
let ret;
121106
loop {
122-
if buf.capacity() == buf.len() {
123-
buf.reserve(DEFAULT_BUF_SIZE);
107+
if len == buf.len() {
108+
if buf.capacity() == buf.len() {
109+
if cap_bump < DEFAULT_BUF_SIZE {
110+
cap_bump *= 2;
111+
}
112+
buf.reserve(cap_bump);
113+
}
114+
let new_area = buf.capacity() - buf.len();
115+
buf.extend(iter::repeat(0).take(new_area));
124116
}
125-
match with_end_to_cap(buf, |b| r.read(b)) {
126-
Ok(0) => return Ok(read),
127-
Ok(n) => read += n,
117+
118+
match r.read(&mut buf[len..]) {
119+
Ok(0) => {
120+
ret = Ok(len - start_len);
121+
break;
122+
}
123+
Ok(n) => len += n,
128124
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
129-
Err(e) => return Err(e),
125+
Err(e) => {
126+
ret = Err(e);
127+
break;
128+
}
130129
}
131130
}
131+
132+
buf.truncate(len);
133+
ret
132134
}
133135

134136
/// A trait for objects which are byte-oriented sources.

branches/tmp/src/libstd/old_io/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ mod test {
15321532
b"foobar\0\0\0\0".to_vec());
15331533

15341534
// Truncate to a smaller length, don't seek, and then write something.
1535-
// Ensure that the intermediate zeroes are all filled in (we're seeked
1535+
// Ensure that the intermediate zeroes are all filled in (we have `seek`ed
15361536
// past the end of the file).
15371537
check!(file.truncate(2));
15381538
assert_eq!(check!(file.stat()).size, 2);

branches/tmp/src/test/compile-fail/issue-9814.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Verify that single-variant enums cant be de-referenced
11+
// Verify that single-variant enums can't be de-referenced
1212
// Regression test for issue #9814
1313

1414
enum Foo { Bar(isize) }

branches/tmp/src/test/debuginfo/generic-struct-style-enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ enum Univariant<T> {
5353

5454
fn main() {
5555

56-
// In order to avoid endianess trouble all of the following test values consist of a single
56+
// In order to avoid endianness trouble all of the following test values consist of a single
5757
// repeated byte. This way each interpretation of the union should look the same, no matter if
5858
// this is a big or little endian machine.
5959

branches/tmp/src/test/debuginfo/generic-tuple-style-enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ enum Univariant<T64> {
7171

7272
fn main() {
7373

74-
// In order to avoid endianess trouble all of the following test values consist of a single
74+
// In order to avoid endianness trouble all of the following test values consist of a single
7575
// repeated byte. This way each interpretation of the union should look the same, no matter if
7676
// this is a big or little endian machine.
7777

0 commit comments

Comments
 (0)