summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-12-21std: Remove some @-boxesBrian Anderson-76/+89
2013-12-20Implement size_hint() for ByRef iteratorPalmer Cox-1/+2
2013-12-20Update next() and size_hint() for MutSpliterIteratorPalmer Cox-11/+8
Update the next() method to just return self.v in the case that we've reached the last element that the iterator will yield. This produces equivalent behavior as before, but without the cost of updating the field. Update the size_hint() method to return a better hint now that #9629 is fixed.
2013-12-20Remove remainder field from MutChunkIterPalmer Cox-13/+10
This field is no longer necessary now that #9629 is fixed since we can just access the length of the remaining slice directly.
2013-12-21std::vec: add a sugary .sort() method for plain Ord sorting.Huon Wilson-7/+64
This moves the custom sorting to `.sort_by`.
2013-12-20auto merge of #10986 : adridu59/rust/patch-new, r=alexcrichtonbors-3/+3
Thanks to @huonw for some mentoring. :cake:
2013-12-20doc: forward-port the conditions tutorial + fixup libstd exampleAdrien Tétar-3/+3
2013-12-20auto merge of #11081 : alexcrichton/rust/comm-adapters, r=huonwbors-2/+5
I accidentally removed this module from compilation awhile back, this adds it back in. Closes #11076
2013-12-19auto merge of #11071 : huonw/rust/quiet-test, r=cmrbors-46/+28
2013-12-20std::vec: implement a stable merge sort, deferring to insertion sort forHuon Wilson-1/+260
very small runs. This uses a lot of unsafe code for speed, otherwise we would be having to sort by sorting lists of indices and then do a pile of swaps to put everything in the correct place. Fixes #9819.
2013-12-19Get comm_adapters building againAlex Crichton-2/+5
I accidentally removed this module from compilation awhile back, this adds it back in. Closes #11076
2013-12-19auto merge of #11041 : cmr/rust/pkgid_changes, r=cmr,metajackbors-0/+2
2013-12-19Rename pkgid to crate_idCorey Richardson-0/+2
Closes #11035
2013-12-20std: silence warnings when compiling test.Huon Wilson-46/+28
2013-12-19auto merge of #11061 : huonw/rust/opt-unsafe-vec, r=alexcrichtonbors-48/+105
Before: ``` test vec::bench::random_inserts ... bench: 15025 ns/iter (+/- 409) test vec::bench::random_removes ... bench: 16063 ns/iter (+/- 276) ``` After: ``` test vec::bench::random_inserts ... bench: 5257 ns/iter (+/- 321) test vec::bench::random_removes ... bench: 4980 ns/iter (+/- 94) ```
2013-12-19std::vec: use some unsafe code to optimise `remove`.Huon Wilson-39/+74
Also, add `.remove_opt` and replace `.unshift` with `.remove(0)`. The code size reduction seem to compensate for not having the optimised special cases. This makes the included benchmark more than 3 times faster.
2013-12-19auto merge of #11065 : huonw/rust/slice-chars-example, r=cmrbors-1/+1
2013-12-19auto merge of #11038 : alexcrichton/rust/fix-osx-leak, r=cmrbors-2/+1
I haven't landed this fix upstream just yet, but it's opened as joyent/libuv#1048. For now, I've locally merged it into my fork, and I've upgraded our repo to point to the new revision. Closes #11027
2013-12-18Upgrade libuv to fix a leak on OSXAlex Crichton-2/+1
I haven't landed this fix upstream just yet, but it's opened as joyent/libuv#1048. For now, I've locally merged it into my fork, and I've upgraded our repo to point to the new revision. Closes #11027
2013-12-18auto merge of #11050 : alexcrichton/rust/snapshots, r=brsonbors-41/+1
Time for a visit from the snapshot fairy!
2013-12-19std::str: fix .slice_chars example. Fixes #11014.Huon Wilson-1/+1
2013-12-19std::vec: replace .insert with a small amount of unsafe code.Huon Wilson-9/+31
This makes the included benchmark more than 3 times faster. Also, `.unshift(x)` is now faster as `.insert(0, x)` which can reuse the allocation if necessary.
2013-12-18auto merge of #11029 : huonw/rust/rm-vec-as-buf, r=cmrbors-319/+196
For `str.as_mut_buf`, un-closure-ification is achieved by outright removal (see commit message). The others are replaced by `.as_ptr`, `.as_mut_ptr` and `.len`
2013-12-19std::str: remove .as_mut_buf & rewrite/simplify `.push_char`.Huon Wilson-23/+6
`.as_mut_buf` was used exactly once, in `.push_char` which could be written in a simpler way, using the `&mut ~[u8]` that it already retrieved. In the rare situation when someone really needs `.as_mut_buf`-like functionality (getting a `*mut u8`), they can go via `str::raw::as_owned_vec`.
2013-12-19std::str: replace .as_imm_buf with .as_ptr.Huon Wilson-101/+68
2013-12-19std::vec: remove .as_muf_buf, replaced by .as_mut_ptr & .len.Huon Wilson-112/+71
2013-12-19std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.Huon Wilson-91/+59
There's no need for the restrictions of a closure with the above methods.
2013-12-18Register new snapshotsAlex Crichton-41/+1
Time for a visit from the snapshot fairy!
2013-12-17auto merge of #11019 : alexcrichton/rust/issue-10545, r=pcwaltonbors-1/+2
This code in resolve accidentally forced all types with an impl to become public. This fixes it by default inheriting the privacy of what was previously there and then becoming `true` if nothing else exits. Closes #10545
2013-12-17auto merge of #10967 : chris-morgan/rust/clean-and-tidy-some-traits, ↵bors-448/+7
r=alexcrichton ### Remove {As,Into,To}{Option,Either,Result} traits. Expanded, that is: - `AsOption` - `IntoOption` - `ToOption` - `AsEither` - `IntoEither` - `ToEither` - `AsResult` - `IntoResult` - `ToResult` These were defined for each other but never *used* anywhere. They are all trivial and so removal will have negligible effect upon anyone. `Either` has fallen out of favour (and its implementation of these traits of dubious semantics), `Option<T>` → `Result<T, ()>` was never really useful and `Result<T, E>` → `Option<T>` should now be done with `Result.ok()` (mirrored with `Result.err()` for even more usefulness). In summary, there's really no point in any of these remaining. ### Rename To{Str,Bytes}Consume traits to Into*. That is: - `ToStrConsume` → `IntoStr`; - `ToBytesConsume` → `IntoBytes`.
2013-12-17auto merge of #10863 : cadencemarseille/rust/patch-handle-ENOENT, r=alexcrichtonbors-3/+8
Translate ENOENT to IoErrorKind::FileNotFound.
2013-12-17Don't allow impls to force public typesAlex Crichton-1/+2
This code in resolve accidentally forced all types with an impl to become public. This fixes it by default inheriting the privacy of what was previously there and then becoming `true` if nothing else exits. Closes #10545
2013-12-17auto merge of #10998 : thestinger/rust/iter, r=alexcrichtonbors-4/+2
2013-12-17Handle ENOENTCadence Marseille-3/+8
Translate ENOENT to IoErrorKind::FileNotFound.
2013-12-17auto merge of #10996 : huonw/rust/more-vec-raw, r=cmrbors-86/+64
The removal of the aliasing &mut[] and &[] from `shift_opt` also comes with its simplification. The above also allows the use of `copy_nonoverlapping_memory` in `[].copy_memory` (I did an audit of each use of `.copy_memory` and `std::vec::bytes::copy_memory`, and I believe none of them are called with arguments can ever alias). This changes requires that `unsafe` code using `copy_memory` **needs** to respect the aliasing rules of `&mut[]`.
2013-12-17auto merge of #10830 : alexcrichton/rust/spsc-queue, r=brsonbors-2467/+3030
This pull request completely rewrites std::comm and all associated users. Some major bullet points * Everything now works natively * oneshots have been removed * shared ports have been removed * try_recv no longer blocks (recv_opt blocks) * constructors are now Chan::new and SharedChan::new * failure is propagated on send * stream channels are 3x faster I have acquired the following measurements on this patch. I compared against Go, but remember that Go's channels are fundamentally different than ours in that sends are by-default blocking. This means that it's not really a totally fair comparison, but it's good to see ballpark numbers for anyway ``` oneshot stream shared1 std 2.111 3.073 1.730 my 6.639 1.037 1.238 native 5.748 1.017 1.250 go8 1.774 3.575 2.948 go8-inf slow 0.837 1.376 go8-128 4.832 1.430 1.504 go1 1.528 1.439 1.251 go2 1.753 3.845 3.166 ``` I had three benchmarks: * oneshot - N times, create a "oneshot channel", send on it, then receive on it (no task spawning) * stream - N times, send from one task to another task, wait for both to complete * shared1 - create N threads, each of which sends M times, and a port receives N*M times. The rows are as follows: * `std` - the current libstd implementation (before this pull request) * `my` - this pull request's implementation (in M:N mode) * `native` - this pull request's implementation (in 1:1 mode) * `goN` - go's implementation with GOMAXPROCS=N. The only relevant value is 8 (I had 8 cores on this machine) * `goN-X` - go's implementation where the channels in question were created with buffers of size `X` to behave more similarly to rust's channels.
2013-12-16Test fallout from std::comm rewriteAlex Crichton-14/+26
2013-12-16libstd: Implement the new `Cell`.Patrick Walton-0/+100
2013-12-16librustc: Implement a `Pod` kind for types that can be `memcpy`'d.Patrick Walton-0/+13
This will be used for the new `Cell`.
2013-12-16Fallout of rewriting std::commAlex Crichton-2033/+387
2013-12-16Rewrite std::commAlex Crichton-434/+2631
* Streams are now ~3x faster than before (fewer allocations and more optimized) * Based on a single-producer single-consumer lock-free queue that doesn't always have to allocate on every send. * Blocking via mutexes/cond vars outside the runtime * Streams work in/out of the runtime seamlessly * Select now works in/out of the runtime seamlessly * Streams will now fail!() on send() if the other end has hung up * try_send() will not fail * PortOne/ChanOne removed * SharedPort removed * MegaPipe removed * Generic select removed (only one kind of port now) * API redesign * try_recv == never block * recv_opt == block, don't fail * iter() == Iterator<T> for Port<T> * removed peek * Type::new * Removed rt::comm
2013-12-17std::vec: make init_elem nicer by doing fewer moves.Huon Wilson-5/+1
2013-12-17std::vec: convert .copy_memory to use copy_nonoverlapping_memory.Huon Wilson-5/+5
It is required that &mut[]s are disjoint from all other &(mut)[]s, so this assumption is ok.
2013-12-17std::vec::bytes: remove the reference to overlapping src and dest inHuon Wilson-7/+4
docs for copy_memory. &mut [u8] and &[u8] really shouldn't be overlapping at all (part of the uniqueness/aliasing guarantee of &mut), so no point in encouraging it.
2013-12-17std::vec::raw: convert copy_memory to a method.Huon Wilson-20/+21
2013-12-17std::vec::raw: convert init_elem to a method.Huon Wilson-16/+16
2013-12-16Make BufferedReader propagate 0-byte long reads.Sébastien Paolacci-3/+3
Could prevent callers from catching the situation and lead to e.g early iterator terminations (cf. `Reader::read_byte') since `None' is only to be returned only on EOF.
2013-12-16Spell out the units used for the `offset` argument, so that people doFelix S. Klock II-1/+5
not try to scale to units of bytes themselves.
2013-12-16vec: avoid some unsafe code in MoveIterator's dtorDaniel Micay-4/+2
2013-12-17std::vec: remove aliasing &mut [] and &[] from shift_opt.Huon Wilson-43/+27
Also, dramatically simplify it with some tasteful raw pointers, rather than treating everything as a nail with `transmute`.