Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to hashbrown's RawTable internally #131

Merged
merged 14 commits into from
Jul 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ language: rust
sudo: false
matrix:
include:
# MSRV is lower for non-dev builds
- rust: 1.18.0
env:
- SKIP_TEST=1
- rust: 1.32.0
- rust: 1.34.2
- rust: stable
Expand Down
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "indexmap"
version = "1.4.0"
version = "1.5.0"
authors = [
"bluss",
"Josh Stone <cuviper@gmail.com>"
Expand Down Expand Up @@ -35,8 +35,13 @@ autocfg = "1"
serde = { version = "1.0", optional = true, default-features = false }
rayon = { version = "1.0", optional = true }

[dependencies.hashbrown]
version = "0.8.1"
default-features = false
features = ["raw"]

[dev-dependencies]
itertools = "0.8"
itertools = "0.9"
rand = {version = "0.7", features = ["small_rng"] }
quickcheck = { version = "0.9", default-features = false }
fnv = "1.0"
Expand Down
31 changes: 22 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ indexmap
.. |docs| image:: https://docs.rs/indexmap/badge.svg
.. _docs: https://docs.rs/indexmap

.. |rustc| image:: https://img.shields.io/badge/rust-1.18%2B-orange.svg
.. _rustc: https://img.shields.io/badge/rust-1.18%2B-orange.svg
.. |rustc| image:: https://img.shields.io/badge/rust-1.32%2B-orange.svg
.. _rustc: https://img.shields.io/badge/rust-1.32%2B-orange.svg

A safe, pure-Rust hash table which preserves (in a limited sense) insertion
order.
A pure-Rust hash table which preserves (in a limited sense) insertion order.

This crate implements compact map and set data-structures,
where the iteration order of the keys is independent from their hash or
Expand Down Expand Up @@ -45,11 +44,6 @@ was indexmap, a hash table that has following properties:
- It's the usual backwards shift deletion, but only on the index vector, so
it's cheaper because it's moving less memory around.

Does not implement (Yet)
------------------------

- ``.reserve()`` exists but does not have a complete implementation

Performance
-----------

Expand Down Expand Up @@ -86,6 +80,25 @@ which is roughly:
Recent Changes
==============

- 1.5.0

- **MSRV**: Rust 1.32 or later is now required.

- The inner hash table is now based on ``hashbrown`` by @cuviper in PR 131_.
This also completes the method ``reserve`` and adds ``shrink_to_fit``.

- Add new methods ``get_key_value``, ``remove_entry``, ``swap_remove_entry``,
and ``shift_remove_entry``, by @cuviper in PR 136_

- ``Clone::clone_from`` reuses allocations by @cuviper in PR 125_

- Add new method ``reverse`` by @linclelinkpart5 in PR 128_

.. _125: https://github.com/bluss/indexmap/pull/125
.. _128: https://github.com/bluss/indexmap/pull/128
.. _131: https://github.com/bluss/indexmap/pull/131
.. _136: https://github.com/bluss/indexmap/pull/136

- 1.4.0

- Add new method ``get_index_of`` by @Thermatrix in PR 115_ and 120_
Expand Down
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// We *mostly* avoid unsafe code, but `map::core::raw` allows it to use `RawTable` buckets.
#![deny(unsafe_code)]
#![doc(html_root_url = "https://docs.rs/indexmap/1/")]
#![cfg_attr(not(has_std), no_std)]
Expand Down Expand Up @@ -53,9 +54,8 @@
//!
//! ### Rust Version
//!
//! This version of indexmap requires Rust 1.18 or later, or 1.32+ for
//! development builds, and Rust 1.36+ for using with `alloc` (without `std`),
//! see below.
//! This version of indexmap requires Rust 1.32 or later, or Rust 1.36+ for
//! using with `alloc` (without `std`), see below.
//!
//! The indexmap 1.x release series will use a carefully considered version
//! upgrade policy, where in a later 1.x version, we will raise the minimum
Expand All @@ -80,9 +80,10 @@
//! [def]: map/struct.IndexMap.html#impl-Default

#[cfg(not(has_std))]
#[macro_use(vec)]
extern crate alloc;

extern crate hashbrown;

#[cfg(not(has_std))]
pub(crate) mod std {
pub use core::*;
Expand All @@ -106,8 +107,6 @@ mod mutable_keys;
mod serde;
mod util;

mod map_core;

pub mod map;
pub mod set;

Expand All @@ -129,8 +128,8 @@ struct HashValue(usize);

impl HashValue {
#[inline(always)]
fn get(self) -> usize {
self.0
fn get(self) -> u64 {
self.0 as u64
}
}

Expand Down
Loading