about summary refs log tree commit diff
path: root/src/liballoc/collections/btree/node.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1488/+0
2020-07-16Clean up or comment every unwrap in BTreeMap's main code.Stein Somers-0/+5
2020-07-13Add and fix BTreeMap commentsStein Somers-6/+9
2020-06-19`#[deny(unsafe_op_in_unsafe_fn)]` in liballocLeSeulArtichaut-22/+32
2020-04-26remove Unique::from for shared pointer typesRalf Jung-1/+1
2020-04-09Respect the comment: no root unless the borrow type is `Mut`Stein Somers-2/+2
2020-04-05Keep track of position when deleting from a BTreeMapAmanieu d'Antras-0/+5
This improves the performance of drain_filter and is needed for future Cursor support for BTreeMap.
2020-03-26Remove alignment from `MemoryBlock`Tim Diekmann-8/+4
2020-03-26Fix issues from review and unsoundness of `RawVec::into_box`Tim Diekmann-7/+12
2020-03-20Drop NodeHeader type from BTree codeMark Rousskov-41/+5
We no longer have a separate header because the shared root is gone; all code can work solely with leafs now.
2020-03-20Make functions dependent only on shared root avoidance safeMark Rousskov-53/+54
2020-03-20Remove shared root code and assertions from BTree nodesMark Rousskov-51/+2
2020-03-08Rollup merge of #69668 - ssomers:btreemap_even_more_comments, r=Mark-SimulacrumMazdak Farrokhzad-14/+19
More documentation and simplification of BTreeMap's internals Salvage the documentation and simplification from #67980, without changing the type locked down by debuginfo. r? @rkruppe
2020-03-06fix various typosMatthias Krüger-1/+1
2020-03-04Documentation and slight simplification of BTreeMap's internalsStein Somers-14/+19
2020-03-03Simplify conditions like x + 1 <= y to x < yMatthias Krüger-1/+1
2020-02-28Auto merge of #68827 - ssomers:btree_navigation_revisited, r=Mark-Simulacrumbors-20/+22
BTreeMap navigation done safer & faster It turns out that there was a faster way to do the tree navigation code bundled in #67073, by moving from edge to KV and from KV to next edge separately. It extracts most of the code as safe functions, and contains the duplication of handles within the short wrapper functions. This somehow hits a sweet spot in the compiler because it reports boosts all over the board: ``` >cargo benchcmp pre3.txt posz4.txt --threshold 5 name pre3.txt ns/iter posz4.txt ns/iter diff ns/iter diff % speedup btree::map::first_and_last_0 40 37 -3 -7.50% x 1.08 btree::map::first_and_last_100 58 44 -14 -24.14% x 1.32 btree::map::iter_1000 8,920 3,419 -5,501 -61.67% x 2.61 btree::map::iter_100000 1,069,290 411,615 -657,675 -61.51% x 2.60 btree::map::iter_20 169 58 -111 -65.68% x 2.91 btree::map::iter_mut_1000 8,701 3,303 -5,398 -62.04% x 2.63 btree::map::iter_mut_100000 1,034,560 405,975 -628,585 -60.76% x 2.55 btree::map::iter_mut_20 165 58 -107 -64.85% x 2.84 btree::set::clone_100 1,831 1,562 -269 -14.69% x 1.17 btree::set::clone_100_and_clear 1,831 1,565 -266 -14.53% x 1.17 btree::set::clone_100_and_into_iter 1,917 1,541 -376 -19.61% x 1.24 btree::set::clone_100_and_pop_all 2,609 2,441 -168 -6.44% x 1.07 btree::set::clone_100_and_remove_all 4,598 3,927 -671 -14.59% x 1.17 btree::set::clone_100_and_remove_half 2,765 2,551 -214 -7.74% x 1.08 btree::set::clone_10k 191,610 164,616 -26,994 -14.09% x 1.16 btree::set::clone_10k_and_clear 192,003 164,616 -27,387 -14.26% x 1.17 btree::set::clone_10k_and_into_iter 200,037 163,010 -37,027 -18.51% x 1.23 btree::set::clone_10k_and_pop_all 267,023 250,913 -16,110 -6.03% x 1.06 btree::set::clone_10k_and_remove_all 536,230 464,100 -72,130 -13.45% x 1.16 btree::set::clone_10k_and_remove_half 453,350 430,545 -22,805 -5.03% x 1.05 btree::set::difference_random_100_vs_100 1,787 801 -986 -55.18% x 2.23 btree::set::difference_random_100_vs_10k 2,978 2,696 -282 -9.47% x 1.10 btree::set::difference_random_10k_vs_100 111,075 54,734 -56,341 -50.72% x 2.03 btree::set::difference_random_10k_vs_10k 246,380 175,980 -70,400 -28.57% x 1.40 btree::set::difference_staggered_100_vs_100 1,789 951 -838 -46.84% x 1.88 btree::set::difference_staggered_100_vs_10k 2,798 2,606 -192 -6.86% x 1.07 btree::set::difference_staggered_10k_vs_10k 176,452 97,401 -79,051 -44.80% x 1.81 btree::set::intersection_100_neg_vs_10k_pos 34 32 -2 -5.88% x 1.06 btree::set::intersection_100_pos_vs_100_neg 30 27 -3 -10.00% x 1.11 btree::set::intersection_random_100_vs_100 1,537 613 -924 -60.12% x 2.51 btree::set::intersection_random_100_vs_10k 2,793 2,649 -144 -5.16% x 1.05 btree::set::intersection_random_10k_vs_10k 222,127 147,166 -74,961 -33.75% x 1.51 btree::set::intersection_staggered_100_vs_100 1,447 622 -825 -57.01% x 2.33 btree::set::intersection_staggered_100_vs_10k 2,606 2,382 -224 -8.60% x 1.09 btree::set::intersection_staggered_10k_vs_10k 143,620 58,790 -84,830 -59.07% x 2.44 btree::set::is_subset_100_vs_100 1,349 488 -861 -63.83% x 2.76 btree::set::is_subset_100_vs_10k 1,720 1,428 -292 -16.98% x 1.20 btree::set::is_subset_10k_vs_10k 135,984 48,527 -87,457 -64.31% x 2.80 ``` The `first_and_last` ones are noise (they don't do iteration), the others seem genuine. As always, approved by Miri. Also, a separate commit with some more benchmarks of mutable behaviour (which also benefit). r? @cuviper
2020-02-28Make implementation of navigation simpler, safer and fasterStein Somers-20/+22
2020-02-07Lift range_search up one level of abstractionStein Somers-0/+9
2020-01-31Bundle and document 6 BTreeMap navigation algorithmsStein Somers-0/+16
2020-01-30Rollup merge of #68468 - ssomers:btreemap_prefer_middle, r=Mark-SimulacrumDylan DPC-115/+123
BTreeMap: tag and explain unsafe internal functions or assert preconditions #68418 concluded that it's not desirable to tag all internal functions with preconditions as being unsafe. This PR does it to some functions, documents why, and elsewhere enforces the preconditions with asserts.
2020-01-29BTreeMap: tag and explain unsafe internal functions or assert preconditionsStein Somers-115/+123
Co-Authored-By: Mark Rousskov <mark.simulacrum@gmail.com>
2020-01-27Rename `Alloc` to `AllocRef`Tim Diekmann-1/+1
2020-01-21Declare unsafe functions that can no longer handle shared rootsStein Somers-4/+4
2020-01-21trade in outdated comments for correct onesStein Somers-2/+2
2020-01-10Simplify NodeHeader by avoiding slices in BTreeMaps with shared rootsStein Somers-49/+6
2020-01-09Apply suggestions from code reviewStein Somers-0/+1
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-01-09Simplify into_key_slice_mut and document bits and bobsStein Somers-13/+9
2020-01-04Tweak and extend internal documentation, including debug asserts.Stein Somers-13/+37
Co-Authored-By: Robin Kruppe <robin.kruppe@gmail.com>
2019-12-26prune ill-conceived BTreeMap iter_mut assertion and test moreStein Somers-24/+30
2019-12-22Format the worldMark Rousskov-392/+224
2019-11-26Fix spelling typosBrian Wignall-1/+1
2019-08-14Handle cfg(bootstrap) throughoutMark Rousskov-3/+3
2019-07-19use const array repeat expressions for uninit_arrayRalf Jung-3/+3
2019-07-01Remove needless lifetimesJeremy Stucki-1/+1
2019-03-26adjust MaybeUninit API to discussionsRalf Jung-5/+5
uninitialized -> uninit into_initialized -> assume_init read_initialized -> read set -> write
2019-02-22Rollup merge of #58431 - RalfJung:btree, r=Mark-SimulacrumMazdak Farrokhzad-3/+22
fix overlapping references in BTree This fixes two kinds of overlapping references in BTree (both found by running the BTree test suite in Miri). In `into_slices_mut`, we did `k.into_key_slice_mut()` followed by `self.into_val_slice_mut()` (where `k` is a copy of `self`). Calling `into_val_slice_mut` calls `self.len()`, which creates a shared reference to `NodeHeader`, which unfortunately (due to padding) overlaps with the mutable reference returned by `into_key_slice_mut`. Hence the key slice got (partially) invalidated. The fix is to avoid creating an `&NodeHeader` after the first slice got created. In the iterators, we used to first create the references that will be returned, and then perform the walk on the tree. Walking the tree creates references (such as `&mut InternalNode`) that overlap with all of the keys and values stored in a pointer; in particular, they overlap with the references the iterator will later return. This is fixed by reordering the operations of walking the tree and obtaining the inner references. The test suite still passes (and it passes in Miri now!), but there is a lot of code here that I do not understand...
2019-02-14split MaybeUninit into several features, expand docs a bitRalf Jung-2/+2
2019-02-13fix invalidating references in BTree iteratorsRalf Jung-1/+1
2019-02-13fix overlapping mutable and shared references in BTreeMap's into_slices_mutRalf Jung-3/+22
2019-02-10libs: doc commentsAlexander Regueiro-2/+2
2019-02-10tests: doc commentsAlexander Regueiro-3/+3
2019-02-03liballoc: revert nested imports style changes.Mazdak Farrokhzad-10/+6
2019-02-02liballoc: fix some idiom lints.Mazdak Farrokhzad-10/+10
2019-02-02liballoc: refactor & fix some imports.Mazdak Farrokhzad-6/+10
2019-02-02liballoc: cargo check passes on 2018Mazdak Farrokhzad-2/+2
2019-01-28rename first_mut_ptr -> first_ptr_mutRalf Jung-5/+5
2019-01-28add macro for creating uninitialized arrayRalf Jung-9/+3
2019-01-28avoid some raw ptr casts in BTreeMapRalf Jung-7/+10
2019-01-28avoid mem::uninitialized in BTreeMapRalf Jung-9/+16