| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
Looks like it is no longer necessary, as uninit_array() can be used
instead in the few cases where it was needed.
|
|
|
|
|
|
|
|
Replace lshift with multiply
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
|
|
const instead of multiple target_pointer_width checks.
|
|
first_ptr -> slice_as_ptr
first_ptr_mut -> slice_as_mut_ptr
slice_get_ref -> slice_assume_init_ref
slice_get_mut -> slice_assume_init_mut
|
|
BTreeMap: introduce marker::ValMut and reserve Mut for unique access
The mutable BTreeMap iterators (apart from `DrainFilter`) are double-ended, meaning they have to rely on a front and a back handle that each represent a reference into the tree. Reserve a type category `marker::ValMut` for them, so that we guarantee that they cannot reach operations on handles with borrow type `marker::Mut`and that these operations can assume unique access to the tree.
Including #75195, benchmarks report no genuine change:
```
benchcmp old new --threshold 5
name old ns/iter new ns/iter diff ns/iter diff % speedup
btree::map::iter_100 3,333 3,023 -310 -9.30% x 1.10
btree::map::range_unbounded_vs_iter 36,624 31,569 -5,055 -13.80% x 1.16
```
r? @Mark-Simulacrum
|
|
Add `slice::check_range`
This method is useful for [`RangeBounds`] parameters. It's even been [rewritten](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/src/librustc_data_structures/sorted_map.rs#L214) [many](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/library/alloc/src/vec.rs#L1299) [times](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/library/core/src/slice/mod.rs#L2441) in the standard library, sometimes assuming that the bounds won't be [`usize::MAX`].
For example, [`Vec::drain`] creates an empty iterator when [`usize::MAX`] is used as an inclusive end bound:
```rust
assert!(vec![1].drain(..=usize::max_value()).eq(iter::empty()));
```
If this PR is merged, I'll create another to use it for those methods.
[`RangeBounds`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html
[`usize::MAX`]: https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.MAX
[`Vec::drain`]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain
|
|
|
|
|
|
|
|
private trait instead
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
|
|
|
|
|
|
|
|
|
|
Revert the fundamental changes in #74762 and #75257
Before possibly going over to #75487. Also contains some added and fixed comments.
r? @Mark-Simulacrum
|
|
Migrate unit tests of btree collections to their native breeding ground
There's one BTreeSet test case that I couldn't easily convince to come along, maybe because it truly is an integration test. But leaving it in place would mean git wouldn't see the move so I also moved it to a new file.
r? @Mark-Simulacrum
|
|
BTreeMap: refactor splitpoint and move testing over to unit test
r? @Mark-Simulacrum
|
|
BTreeMap: purge innocent use of into_kv_mut
Replace the use of `into_kv_mut` into more precise calls. This makes more sense if you know that the single remaining use of `into_kv_mut` is in fact evil and can be trialled in court (#75200) and sent to a correction facility (#73971).
No real performance difference reported (but functions that might benefit a tiny constant bit like `BTreeMap::get_mut` aren't benchmarked):
```
benchcmp old new --threshold 5
name old ns/iter new ns/iter diff ns/iter diff % speedup
btree::map::clone_fat_100 63,073 59,256 -3,817 -6.05% x 1.06
btree::map::iter_100 3,514 3,235 -279 -7.94% x 1.09
```
|
|
|
|
|
|
|
|
Stop BTreeMap casts from reborrowing
Down in btree/node.rs, the interface and use of `cast_unchecked` look a bit shady. It's really just there for inverting `forget_type` which does not borrow. By borrowing we can't write the same `cast_unchecked` in the same way at the Handle level.
No change in undefined behaviour or performance.
|
|
|
|
|
|
|
|
|
|
Deriving debug prints all the values including keys. But ValuesMut
struct should only print the values.
|
|
|
|
|
|
Implement `into_keys` and `into_values` for associative maps
This PR implements `into_keys` and `into_values` for HashMap and BTreeMap types. They are implemented as unstable, under `map_into_keys_values` feature.
Fixes #55214.
r? @dtolnay
|
|
|
|
|
|
BTreeMap: better way to postpone root access in DrainFilter
A slightly more elegant (in my opinion) adaptation of #74762. Benchmarks seem irrationally pleased to:
```
benchcmp old new --threshold 5
name old ns/iter new ns/iter diff ns/iter diff % speedup
btree::map::clone_fat_100_and_remove_all 215,182 185,052 -30,130 -14.00% x 1.16
btree::map::clone_fat_100_and_remove_half 139,667 127,945 -11,722 -8.39% x 1.09
btree::map::clone_fat_val_100_and_remove_all 96,755 81,279 -15,476 -16.00% x 1.19
btree::map::clone_fat_val_100_and_remove_half 64,678 56,911 -7,767 -12.01% x 1.14
btree::map::find_rand_100 18 17 -1 -5.56% x 1.06
btree::map::first_and_last_0 33 35 2 6.06% x 0.94
btree::map::first_and_last_100 40 54 14 35.00% x 0.74
btree::map::insert_rand_100 45 42 -3 -6.67% x 1.07
btree::map::insert_rand_10_000 45 41 -4 -8.89% x 1.10
btree::map::iter_0 2,010 1,759 -251 -12.49% x 1.14
btree::map::iter_100 3,514 2,764 -750 -21.34% x 1.27
btree::map::iter_10k 4,018 3,768 -250 -6.22% x 1.07
btree::map::range_unbounded_unbounded 37,269 28,929 -8,340 -22.38% x 1.29
btree::map::range_unbounded_vs_iter 31,518 28,814 -2,704 -8.58% x 1.09
```
r? @Mark-Simulacrum
|
|
BTreeMap: enforce the panic rule imposed by `replace`
Also, reveal the unsafe parts in the closures fed to it.
r? @Mark-Simulacrum
|
|
|
|
|