| Age | Commit message (Collapse) | Author | Lines |
|
I fixed a single character typo.
r? @steveklabnik
|
|
Pretty sure this should apply to the module.
r? @alexcrichton
|
|
|
|
into rollup_central
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In general, it's undesirable to have read_to_end use a buffer with uninitialized memory, as that could lead to undefined behaviour in the event of a bad Read implementation. Since we control the implementations of Read for Stdin and File, however, it should be okay for us to specialise them to improve performance. This PR is to do that!
Adds some unsafe code to deal with creating the buffers. Since the read_to_end function needed to be used from the io and fs crates, I moved it into a newly-created sys::common::io module. Alternatively we could expose the new read_to_end functions to allow people to create their own read_to_end implementations for code they trust.
Benchmarks:
Read a 2.5MB file:
sys_common::io::tests::bench_init_file ... bench: 27,473,317 ns/iter (+/- 2,490,767)
sys_common::io::tests::bench_uninit_file ... bench: 25,611,793 ns/iter (+/- 2,137,387)
Read a buffer full of constant values
sys_common::io::tests::bench_uninitialized ... bench: 12,877,645 ns/iter (+/- 931,025)
sys_common::io::tests::bench_zeroed ... bench: 18,581,082 ns/iter (+/- 1,541,108)
So, approx a 7% speedup for file reading, which I think is worthwhile.
|
|
Yet another attempt to make the prose on the std crate page
clearer and more informative.
This does a lot of things: tightens up the opening, adds useful links
(including a link to the search bar), offers guidance on how to use
the docs, and expands the prelude docs as a useful newbie entrypoint.
r? @steveklabnik cc @aturon
|
|
allowing them to read into a buffer containing uninitialized data,
rather than pay the cost of zeroing.
|
|
|
|
|
|
Use Vec::drain in BufWriter
I happened past a comment that asked for functionality that we now have.
|
|
I happened past a comment that asked for functionality that we now have.
|
|
|
|
|
|
Yet another attempt to make the prose on the std crate page
clearer and more informative.
This does a lot of things: tightens up the opening, adds useful links
(including a link to the search bar), offers guidance on how to use
the docs, and expands the prelude docs as a useful newbie entrypoint.
|
|
See https://github.com/rust-lang/rfcs/issues/1157
|
|
... matching the existing Index impls.
There is no reason not to if String implement DerefMut.
The code removed in `src/librustc/middle/effect.rs` was added in #9750
to prevent things like `s[0] = 0x80` where `s: String`,
but I belive became unnecessary when the Index(Mut) traits were introduced.
|
|
|
|
|
|
TLS tests have been deadlocking on the OSX bots for quite some time now and this
commit is the result of the investigation into what's going on. It turns out
that a value in TLS which is being destroyed (e.g. the destructor is run) can be
reset back to the initial state **while the destructor is running** if TLS is
re-accessed.
To fix this we stop calling drop_in_place on OSX and instead move the data to a
temporary location on the stack.
|
|
TLS tests have been deadlocking on the OSX bots for quite some time now and this
commit is the result of the investigation into what's going on. It turns out
that a value in TLS which is being destroyed (e.g. the destructor is run) can be
reset back to the initial state **while the destructor is running** if TLS is
re-accessed.
To fix this we stop calling drop_in_place on OSX and instead move the data to a
temporary location on the stack.
|
|
Fixes #26900
|
|
Use escaped byte string representation for CString Debug
Faithfully represent the contents of the CString and CStr in their Debug
impl, by treating them as byte strings with our default escaping to
ascii representation.
Add impl Debug for CStr.
Fixes #26964.
|
|
- It is clear that what follows are re-exports
- There aren't so many re-exports that examples should be given
|
|
The File object needs to be writable for the set_len to succeed.
|
|
this adds support for i686-unknown-freebsd target.
|
|
- It is clear that what follows are re-exports
- There aren't so many re-exports that examples should be given
|
|
The File object needs to be writable for the truncate to succeed.
|
|
Faithfully represent the contents of the CString and CStr in their Debug
impl, by treating them as byte strings with our default escaping to
ascii representation.
Add impl Debug for Cstr.
Fixes #26964.
|
|
|
|
Small tweaks for the documentation of the primitive type array
Follow up to PR #26923, fix a few small details.
|
|
|
|
This round: io::Result and the free functions.
|
|
Mostly just adding basic examples, what's there seems mostly good.
r? @alexcrichton
|
|
Previously on Windows a directory junction would return false from `is_dir`,
causing various odd behavior, specifically calls to `create_dir_all` might fail
when they would otherwise continue to succeed.
Closes #26716
|
|
This makes `Debug` for `File` show the file path and access mode of the file on OS X, just like on Linux.
I'd be happy about any feedback how to make this code better. In particular, I'm not sure how to handle the buffer passed to `fnctl`. This way works, but it feels a bit cumbersome. `fcntl` unfortunately doesn't return the length of the path.
|
|
|
|
|
|
(On Windows, it works already.)
|
|
Previously on Windows a directory junction would return false from `is_dir`,
causing various odd behavior, specifically calls to `create_dir_all` might fail
when they would otherwise continue to succeed.
Closes #26716
|
|
This allows CString and CStr to be used with the Cow type,
which is extremely useful when interfacing with C libraries
that make extensive use of C-style strings.
|
|
This round: io::Result and the free functions.
|
|
|
|
|
|
Using the OS mechanism for copying files allows the OS to optimize the transfer using stuff such as [Offloaded Data Transfers (ODX)](https://msdn.microsoft.com/en-us/library/windows/desktop/hh848056%28v=vs.85%29.aspx).
Also preserves a lot more information, including NTFS [File Streams](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364404%28v=vs.85%29.aspx), which the manual implementation threw away.
In addition, it is an atomic operation, unlike the manual implementation which has extra calls for copying over permissions.
r? @alexcrichton
|