| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Unique pointers and vectors currently contain a reference counting
header when containing a managed pointer.
This `{ ref_count, type_desc, prev, next }` header is not necessary and
not a sensible foundation for tracing. It adds needless complexity to
library code and is responsible for breakage in places where the branch
has been left out.
The `borrow_offset` field can now be removed from `TyDesc` along with
the associated handling in the compiler.
Closes #9510
Closes #11533
|
|
|
|
The `print!` and `println!` macros are now the preferred method of printing, and so there is no reason to export the `stdio` functions in the prelude. The functions have also been replaced by their macro counterparts in the tutorial and other documentation so that newcomers don't get confused about what they should be using.
|
|
Turned out to be a 2-line fix, but the compiler fallout was huge.
|
|
|
|
Fallout from the previous commits
|
|
|
|
This method is primarily intended to allow for converting a [T, ..N] to
a &mut [T].
|
|
This commit uniforms the short title of modules provided by libstd,
in order to make their roles more explicit when glancing at the index.
Signed-off-by: Luca Bruno <lucab@debian.org>
|
|
|
|
This commit brings the library up-to-date in order to get all tests passing
again
|
|
|
|
examples/clarification to others.
|
|
|
|
|
|
This uses quite a bit of unsafe code for speed and failure safety, and allocates `2*n` temporary storage.
[Performance](https://gist.github.com/huonw/5547f2478380288a28c2):
| n | new | priority_queue | quick3 |
|-------:|---------:|---------------:|---------:|
| 5 | 200 | 155 | 106 |
| 100 | 6490 | 8750 | 5810 |
| 10000 | 1300000 | 1790000 | 1060000 |
| 100000 | 16700000 | 23600000 | 12700000 |
| sorted | 520000 | 1380000 | 53900000 |
| trend | 1310000 | 1690000 | 1100000 |
(The times are in nanoseconds, having subtracted the set-up time (i.e. the `just_generate` bench target).)
I imagine that there is still significant room for improvement, particularly because both priority_queue and quick3 are doing a static call via `Ord` or `TotalOrd` for the comparisons, while this is using a (boxed) closure.
Also, this code does not `clone`, unlike `quick_sort3`; and is stable, unlike both of the others.
|
|
(implicitly) less_eq.
|
|
|
|
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.
|
|
This field is no longer necessary now that #9629 is fixed since we can just
access the length of the remaining slice directly.
|
|
This moves the custom sorting to `.sort_by`.
|
|
|
|
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.
|
|
|
|
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)
```
|
|
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.
|
|
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.
|
|
|
|
There's no need for the restrictions of a closure with the above methods.
|
|
|
|
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[]`.
|
|
|
|
It is required that &mut[]s are disjoint from all other &(mut)[]s, so
this assumption is ok.
|
|
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.
|
|
|
|
|
|
|
|
Also, dramatically simplify it with some tasteful raw pointers, rather
than treating everything as a nail with `transmute`.
|
|
Closes #10976
|
|
|
|
See commits for details.
|
|
|
|
|
|
This can easily be written as `(*v.unsafe_ref(i)).clone()`, or just
`*v.unsafe_ref(i)` for primitive types like `i32` (the common case).
|
|
|
|
These are less useful versions of the comparison operators and TotalOrd
trait.
|
|
raw}::copy_memory.
Slices carry their length with them, so we can just use that
information.
|
|
|
|
* fixes the vec::from_elem regression caused by #8780
* added 5 benchmarks for allocating a 1KB ~[u8] and zeroing it
|