Mercurial > hg
comparison rust/hg-core/Cargo.toml @ 48950:11c0411bf4e2
dirstate-tree: optimize HashMap lookups with raw_entry_mut
This switches to using `HashMap` from the hashbrown crate,
in order to use its `raw_entry_mut` method.
The standard library’s `HashMap` is also based on this same crate,
but `raw_entry_mut` is not yet stable there:
https://github.com/rust-lang/rust/issues/56167
Using version 0.9 because 0.10 is yanked and 0.11 requires Rust 1.49
This replaces in `DirstateMap::get_or_insert_node` a call to
`HashMap<K, V>::entry` with `K = WithBasename<Cow<'on_disk, HgPath>>`.
`entry` takes and consumes an "owned" `key: K` parameter, in case a new entry
ends up inserted. This key is converted by `to_cow` from a value that borrows
the `'path` lifetime.
When this function is called by `Dirstate::new_v1`, `'path` is in fact
the same as `'on_disk` so `to_cow` can return an owned key that contains
`Cow::Borrowed`.
For other callers, `to_cow` needs to create a `Cow::Owned` and thus make
a costly heap memory allocation. This is wasteful if this key was already
present in the map. Even when inserting a new node this is typically the case
for its ancestor nodes (assuming most directories have numerous descendants).
Differential Revision: https://phab.mercurial-scm.org/D12317
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 08 Feb 2022 15:51:52 +0100 |
parents | 0dc698c91ca0 |
children | ec8d9b5a5e7c |
comparison
equal
deleted
inserted
replaced
48949:469b9ee336a6 | 48950:11c0411bf4e2 |
---|---|
11 [dependencies] | 11 [dependencies] |
12 bitflags = "1.2" | 12 bitflags = "1.2" |
13 bytes-cast = "0.2" | 13 bytes-cast = "0.2" |
14 byteorder = "1.3.4" | 14 byteorder = "1.3.4" |
15 derive_more = "0.99" | 15 derive_more = "0.99" |
16 hashbrown = {version = "0.9.1", features = ["rayon"]} | |
16 home = "0.5" | 17 home = "0.5" |
17 im-rc = "15.0.*" | 18 im-rc = "15.0.*" |
18 itertools = "0.9" | 19 itertools = "0.9" |
19 lazy_static = "1.4.0" | 20 lazy_static = "1.4.0" |
20 libc = "0.2" | 21 libc = "0.2" |