about summary refs log tree commit diff
path: root/src/libstd/collections/hash/table.rs
AgeCommit message (Collapse)AuthorLines
2019-04-24Replace the robin-hood hash table with hashbrownAmanieu d'Antras-1131/+0
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-7/+7
2019-02-28libstd => 2018Taiki Endo-9/+8
2019-02-20Rollup merge of #58553 - scottmcm:more-ihle, r=Centrilkennytm-16/+16
Use more impl header lifetime elision Inspired by seeing explicit lifetimes on these two: - https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator - https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not And a follow-up to https://github.com/rust-lang/rust/pull/54687, that started using IHLE in libcore. Most of the changes in here fall into two big categories: - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm). I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
2019-02-17Use more impl header lifetime elisionScott McMurray-16/+16
There are two big categories of changes in here - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-10libs: doc commentsAlexander Regueiro-6/+6
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-21Inline tweaksJohn Kåre Alsaker-0/+3
2018-11-30Inline thingsJohn Kåre Alsaker-0/+4
2018-08-29fix some uses of pointer intrinsics with invalid pointersRalf Jung-1/+3
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-2/+2
2018-06-29Move core::alloc::CollectionAllocErr to alloc::collectionsSimon Sapin-1/+2
2018-06-18Rename OOM to allocation errorSimon Sapin-2/+2
The acronym is not descriptive unless one has seen it before. * Rename the `oom` function to `handle_alloc_error`. It was **stabilized in 1.28**, so if we do this at all we need to land it this cycle. * Rename `set_oom_hook` to `set_alloc_error_hook` * Rename `take_oom_hook` to `take_alloc_error_hook` Bikeshed: `alloc` v.s. `allocator`, `error` v.s. `failure`
2018-06-11Remove alloc::Opaque and use *mut u8 as pointer type for GlobalAllocMike Hommey-1/+1
2018-06-04Optimize layout calculations in HashMapAmanieu d'Antras-3/+16
This now produces the same assembly code as the previous implementation.
2018-06-01Simplify HashMap layout calculation by using LayoutAmanieu d'Antras-107/+13
2018-05-30Pass a `Layout` to `oom`Mike Hommey-11/+32
As discussed in https://github.com/rust-lang/rust/issues/49668#issuecomment-384893456 and subsequent, there are use-cases where the OOM handler needs to know the size of the allocation that failed. The alignment might also be a cause for allocation failure, so providing it as well can be useful.
2018-04-29Fix some broken links in docs.Eric Huss-1/+1
2018-04-22Replace GlobalAlloc::oom with a lang itemSteven Fackler-3/+3
2018-04-16Auto merge of #48945 - clarcharr:iter_exhaust, r=Kimundibors-1/+1
Replace manual iterator exhaust with for_each(drop) This originally added a dedicated method, `Iterator::exhaust`, and has since been replaced with `for_each(drop)`, which is more idiomatic. <del>This is just shorthand for `for _ in &mut self {}` or `while let Some(_) = self.next() {}`. This states the intent a lot more clearly than the identical code: run the iterator to completion. <del>At least personally, my eyes tend to gloss over `for _ in &mut self {}` without fully paying attention to what it does; having a `Drop` implementation akin to: <del>`for _ in &mut self {}; unsafe { free(self.ptr); }`</del> <del>Is not as clear as: <del>`self.exhaust(); unsafe { free(self.ptr); }` <del>Additionally, I've seen debate over whether `while let Some(_) = self.next() {}` or `for _ in &mut self {}` is more clear, whereas `self.exhaust()` is clearer than both.
2018-04-12Rename alloc::Void to alloc::OpaqueSimon Sapin-1/+1
2018-04-12Use NonNull<Void> instead of *mut u8 in the Alloc traitMike Hommey-4/+2
Fixes #49608
2018-04-12Return Result instead of Option in alloc::Layout constructorsSimon Sapin-1/+1
2018-04-12Remove the now-unit-struct AllocErr field inside CollectionAllocErrSimon Sapin-2/+2
2018-04-12Remove the now-unit-struct AllocErr parameter of oom()Simon Sapin-2/+2
2018-04-12Actually deprecate the Heap typeSimon Sapin-6/+6
2018-04-12Import the `alloc` crate as `alloc_crate` in stdSimon Sapin-4/+1
… to make the name `alloc` available.
2018-04-04Replace manual iter exhaust with for_each(drop).Clar Charr-1/+1
2018-04-03Remove all unstable placement featuresAidan Hobson Sayers-26/+0
Closes #22181, #27779
2018-04-02Use Alloc and Layout from core::heap.Mike Hommey-1/+2
94d1970bba87f2d2893f6e934e4c3f02ed50604d moved the alloc::allocator module to core::heap, moving e.g. Alloc and Layout out of the alloc crate. While alloc::heap reexports them, it's better to use them from where they really come from.
2018-03-14implementing fallible allocation API (try_reserve) for Vec, String and HashMapsnf-16/+41
2018-01-20Rename std::ptr::Shared to NonNullSimon Sapin-3/+3
`Shared` is now a deprecated `type` alias. CC https://github.com/rust-lang/rust/issues/27730#issuecomment-352800629
2017-12-13Remove Sync and Send implementation for RawTableKonrad Borowski-3/+0
The implementation was introduced when changing hash storage from Unique to *mut, but it was changed back to Unique.
2017-10-14std: Set probe length tag on cloned hashmapsManish Goregaokar-0/+1
This isn't strictly necessary for hashmap cloning to work. The tag is used to hint for an upcoming resize, so it's good to copy this information over. (We can do cleverer things like actually resizing the hashmap when we see the tag, or even cleaning up the entry order, but this requires more thought and might not be worth it)
2017-10-14std: Get rid of hash_offet in RawTableManish Goregaokar-16/+15
This offset is always zero, and we don't consistently take it into account. This is okay, because it's zero, but if it ever changes we're going to have bugs (e.g. in the `dealloc` call, where we don't take it into account). It's better to remove this for now; if we ever have a need for a nonzero offset we can add it back, and handle it properly when we do so.
2017-09-30address some `FIXME`s whose associated issues were marked as closedNiv Kaminer-2/+2
remove FIXME(#13101) since `assert_receiver_is_total_eq` stays. remove FIXME(#19649) now that stability markers render. remove FIXME(#13642) now the benchmarks were moved. remove FIXME(#6220) now that floating points can be formatted. remove FIXME(#18248) and write tests for `Rc<str>` and `Rc<[u8]>` remove reference to irelevent issues in FIXME(#1697, #2178...) update FIXME(#5516) to point to getopts issue 7 update FIXME(#7771) to point to RFC 628 update FIXME(#19839) to point to issue 26925
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-7/+7
Like #43008 (f668999), but _much more aggressive_.
2017-08-01Fixed extra cases found in better checking.Isaac van Bakel-1/+1
2017-07-22Add conversions from references to NonZero pointers, Unique, and SharedSimon Sapin-1/+1
2017-07-22Rename {NonZero,Shared,Unique}::new to new_uncheckedSimon Sapin-3/+3
2017-07-05rustc: Implement the #[global_allocator] attributeAlex Crichton-6/+5
This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/197 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
2017-05-20migrate everything to using mem::needs_dropAlexis Beingessner-2/+1
2017-05-04Deprecate heap::EMPTY in favour of Unique::empty or otherwise.Alexis Beingessner-1/+2
2017-05-04fallout from NonZero/Unique/Shared changesAlexis Beingessner-9/+12
2017-04-04Simplify HashMap Bucket interfacearthurprs-173/+151
* Store capacity_mask instead of capacity * Move bucket index into RawBucket * Bucket index is now always within [0..table_capacity) * Clone RawTable using RawBucket * Simplify iterators by moving logic into RawBuckets * Make retain aware of the number of elements
2017-03-22Simplify hash table dropsJosh Stone-47/+18
This replaces the `std::collections::hash::table::RevMoveBuckets` iterator with a simpler `while` loop. This iterator was only used for dropping the remaining elements of a `RawTable`, so instead we can just loop through directly and drop them in place. This should be functionally equivalent to the former code, but a little easier to read. I was hoping it might have some performance benefit too, but it seems the optimizer was already good enough to see through the iterator -- the generated code is nearly the same. Maybe it will still help if an element type has more complicated drop code.
2017-03-17Stabilize rc_raw feature, closes #37197Aaron Turon-1/+1
2017-03-11Implement placement-in protocol for `HashMap`Charlie Fan-0/+27
2017-03-03Reduce size overhead of adaptative hashmaparthurprs-8/+66
Exposes a boolean flag in RawTable and use it instead of a bool field in HashMap. Fixes: #40042
2017-02-08std: Add retain method for HashMap and HashSetf001-7/+74
Fix #36648