about summary refs log tree commit diff
path: root/src/libstd/vec.rs
AgeCommit message (Collapse)AuthorLines
2014-02-22Move std::num::Integer to libnumBrendan Zabarauskas-3/+3
2014-02-20Mass rename if_ok! to try!Alex Crichton-3/+3
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-20move extra::test to libtestLiigo Zhuang-1/+2
2014-02-15auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfacklerbors-4/+4
It's too easy to forget the `rust` tag to test something. Closes #11698
2014-02-15auto merge of #12272 : alexcrichton/rust/snapshot, r=kballardbors-4/+2
This notably contains the `extern mod` => `extern crate` change. Closes #9880
2014-02-15std: clean up ptr a bitCorey Richardson-38/+38
2014-02-14Fix all code examplesAlex Crichton-4/+4
2014-02-14Register new snapshotsAlex Crichton-4/+2
This enables the parser error for `extern mod` => `extern crate` transitions.
2014-02-14return value/use extra::test::black_box in benchmarkslpy-8/+11
2014-02-13remove duplicate function from std::ptr (is_null, is_not_null, offset, ↵JeremyLetang-10/+11
mut_offset)
2014-02-13Add some missing Show implementations in libstdBrendan Zabarauskas-0/+42
2014-02-11vec -- introduce local var to make clear what subportion is being borrowedNiko Matsakis-2/+2
2014-02-11std -- replaces uses where const borrows would be requiredNiko Matsakis-18/+21
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-10/+9
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-09std: Stop parameterizing some memcpy functions over RawPtrBrian Anderson-8/+8
It unsafe assumptions that any impl of RawPtr is for actual pointers, that they can be copied by memcpy. Removing it is easy, so I don't think it's solving a real problem.
2014-02-09std: Add move_val_init to mem. Replace direct intrinsic usageBrian Anderson-6/+5
2014-02-07auto merge of #12029 : zkamsler/rust/merge-sort-allocations, r=huonwbors-5/+104
This pull request: 1) Changes the initial insertion sort to be in-place, and defers allocation of working set until merge is needed. 2) Increases the increases the maximum run length to use insertion sort for from 8 to 32 elements. This increases the size of vectors that will not allocate, and reduces the number of merge passes by two. It seemed to be the sweet spot in the benchmarks that I ran. Here are the results of some benchmarks. Note that they are sorting u64s, so types that are more expensive to compare or copy may have different behaviors. Before changes: ``` test vec::bench::sort_random_large bench: 719753 ns/iter (+/- 130173) = 111 MB/s test vec::bench::sort_random_medium bench: 4726 ns/iter (+/- 742) = 169 MB/s test vec::bench::sort_random_small bench: 344 ns/iter (+/- 76) = 116 MB/s test vec::bench::sort_sorted bench: 437244 ns/iter (+/- 70043) = 182 MB/s ``` Deferred allocation (8 element insertion sort): ``` test vec::bench::sort_random_large bench: 702630 ns/iter (+/- 88158) = 113 MB/s test vec::bench::sort_random_medium bench: 4529 ns/iter (+/- 497) = 176 MB/s test vec::bench::sort_random_small bench: 185 ns/iter (+/- 49) = 216 MB/s test vec::bench::sort_sorted bench: 425853 ns/iter (+/- 60907) = 187 MB/s ``` Deferred allocation (16 element insertion sort): ``` test vec::bench::sort_random_large bench: 692783 ns/iter (+/- 165837) = 115 MB/s test vec::bench::sort_random_medium bench: 4434 ns/iter (+/- 722) = 180 MB/s test vec::bench::sort_random_small bench: 187 ns/iter (+/- 38) = 213 MB/s test vec::bench::sort_sorted bench: 393783 ns/iter (+/- 85548) = 203 MB/s ``` Deferred allocation (32 element insertion sort): ``` test vec::bench::sort_random_large bench: 682556 ns/iter (+/- 131008) = 117 MB/s test vec::bench::sort_random_medium bench: 4370 ns/iter (+/- 1369) = 183 MB/s test vec::bench::sort_random_small bench: 179 ns/iter (+/- 32) = 223 MB/s test vec::bench::sort_sorted bench: 358353 ns/iter (+/- 65423) = 223 MB/s ``` Deferred allocation (64 element insertion sort): ``` test vec::bench::sort_random_large bench: 712040 ns/iter (+/- 132454) = 112 MB/s test vec::bench::sort_random_medium bench: 4425 ns/iter (+/- 784) = 180 MB/s test vec::bench::sort_random_small bench: 179 ns/iter (+/- 81) = 223 MB/s test vec::bench::sort_sorted bench: 317812 ns/iter (+/- 62675) = 251 MB/s ``` This is the best I could manage with the basic merge sort while keeping the invariant that the original vector must contain each element exactly once when the comparison function is called. If one is not married to a stable sort, an in-place n*log(n) sorting algorithm may have better performance in some cases. for #12011 cc @huonw
2014-02-07Reduced allocations in merge_sort for short vectorsZach Kamsler-5/+104
Added a seperate in-place insertion sort for short vectors. Increased threshold for insertion short for 8 to 32 elements for small types and 16 for larger types. Added benchmarks for sorting larger types.
2014-02-05Implement clone() for TCP/UDP/Unix socketsAlex Crichton-1/+1
This is part of the overall strategy I would like to take when approaching issue #11165. The only two I/O objects that reasonably want to be "split" are the network stream objects. Everything else can be "split" by just creating another version. The initial idea I had was the literally split the object into a reader and a writer half, but that would just introduce lots of clutter with extra interfaces that were a little unnnecssary, or it would return a ~Reader and a ~Writer which means you couldn't access things like the remote peer name or local socket name. The solution I found to be nicer was to just clone the stream itself. The clone is just a clone of the handle, nothing fancy going on at the kernel level. Conceptually I found this very easy to wrap my head around (everything else supports clone()), and it solved the "split" problem at the same time. The cloning support is pretty specific per platform/lib combination: * native/win32 - uses some specific WSA apis to clone the SOCKET handle * native/unix - uses dup() to get another file descriptor * green/all - This is where things get interesting. When we support full clones of a handle, this implies that we're allowing simultaneous writes and reads to happen. It turns out that libuv doesn't support two simultaneous reads or writes of the same object. It does support *one* read and *one* write at the same time, however. Some extra infrastructure was added to just block concurrent writers/readers until the previous read/write operation was completed. I've added tests to the tcp/unix modules to make sure that this functionality is supported everywhere.
2014-02-04auto merge of #11951 : dmanescu/rust/reserve-rename, r=huonwbors-14/+14
Changes in std::{str,vec,hashmap} and extra::{priority_queue,ringbuf}. Fixes #11949
2014-02-04Rename reserve to reserve_exact and reserve_at_least to reserveDavid Manescu-14/+14
Changes in std::{str,vec,hashmap} and extra::{priority_queue,ringbuf}. Fixes #11949
2014-02-01auto merge of #11974 : huonw/rust/no-at-vec, r=pcwaltonbors-60/+0
This removes @[] from the parser as well as much of the handling of it (and `@str`) from the compiler as I can find. I've just rebased @pcwalton's (already reviewed) `@str` removal (and fixed the problems in a separate commit); the only new work is the trailing commits with my authorship. Closes #11967
2014-02-02std,extra: remove use of & support for @[].Huon Wilson-60/+0
2014-02-01auto merge of #11944 : nathanielherman/rust/vec_opt, r=alexcrichtonbors-50/+52
Closes #11733
2014-02-01auto merge of #11930 : bjz/rust/next_power_of_two, r=huonwbors-2/+2
2014-01-31Fix minor doc typosVirgile Andreani-1/+1
2014-01-31Introduce marker types for indicating variance and for opting outNiko Matsakis-9/+10
of builtin bounds. Fixes #10834. Fixes #11385. cc #5922.
2014-02-01Make next_power_of_two generic for unsigned integersBrendan Zabarauskas-2/+2
Also rename `next_power_of_two_opt` to `checked_next_power_of_two`.
2014-01-30Make mut_last return Option instead of failing on empty vector (and add a ↵Nathaniel Herman-4/+14
test for mut_last)
2014-01-30Make pop_ref and mut_pop_ref return Option instead of failing on empty vectorsNathaniel Herman-24/+20
2014-01-30Make shift_ref and mut_shift_ref return Option instead of failingNathaniel Herman-24/+20
2014-01-28Rename ImmutableCopyableVector to ImmutableCloneableVectorVirgile Andreani-2/+2
2014-01-28Rename OwnedCopyableVector to OwnedCloneableVectorVirgile Andreani-2/+2
2014-01-28Rename CopyableVector to CloneableVectorVirgile Andreani-5/+5
2014-01-25Uppercase numeric constantsChris Wong-3/+3
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-23Update flip() to be rev().Sean Chalmers-11/+11
Consensus leaned in favour of using rev instead of flip.
2014-01-23Rename Invert to Flip - Issue 10632Sean Chalmers-11/+11
Renamed the invert() function in iter.rs to flip(). Also renamed the Invert<T> type to Flip<T>. Some related code comments changed. Documentation that I could find has been updated, and all the instances I could locate where the function/type were called have been updated as well.
2014-01-22vec: make unsafe indexing functions higher-levelDaniel Micay-6/+6
2014-01-22Replace C types with Rust types in libstd, closes #7313Florian Hahn-5/+4
2014-01-21[std::vec] Rename .remove_opt() to .remove(), drop the old .remove() behaviorSimon Sapin-47/+13
2014-01-21[std::vec] Rename .shift_opt() to .shift(), drop the old .shift() behaviorSimon Sapin-23/+8
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-25/+6
2014-01-21[std::vec] Rename .last_opt() to .last(), drop the old .last() behaviorSimon Sapin-28/+5
2014-01-21[std::vec] Rename .head_opt() to .head(), drop the old .head() behaviorSimon Sapin-28/+5
2014-01-21[std::vec] Rename .get_opt() to .get()Simon Sapin-6/+6
2014-01-18Rename iterators for consistencyPalmer Cox-71/+71
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
2014-01-17auto merge of #11585 : nikomatsakis/rust/issue-3511-rvalue-lifetimes, r=pcwaltonbors-0/+29
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way. r? @pcwalton
2014-01-15Remove FIXMEs and add licenseNiko Matsakis-1/+1
2014-01-15Issue #3511 - Rationalize temporary lifetimes.Niko Matsakis-1/+30
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way.
2014-01-15register snapshotsDaniel Micay-144/+0