Skip to content

maybe expose a way to pass pre-calculated hashes along with hash table keys #10661

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

Closed
thestinger opened this issue Nov 26, 2013 · 2 comments
Closed
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@thestinger
Copy link
Contributor

I found this was necessarily to avoid double-hashing with a shard-based concurrent hash table like Java's ConcurrentHashMap as the hash needs to be calculated to pick the correct shard.

https://github.com/thestinger/rust-core/blob/master/core/concurrent.rs#L299

This could be done by hoisting out the open-addressing implementation, but it will result in it requiring the hashes to be stored in the table rather than it just being an implementation detail.

@cgaebel
Copy link
Contributor

cgaebel commented Feb 15, 2014

It'd probably need an unsafe tag, and a debug assertation from #12108, but given those I don't see why the HashMap can't support unsafe pub fn insert_hashed(hash: u64, k: K, v: V)

@steveklabnik
Copy link
Member

I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

This issue has been moved to the RFCs repo: rust-lang/rfcs#794

flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 23, 2023
…stion, r=Manishearth

Add `manual_slice_size_calculation` applicable suggestion

Continuation of rust-lang/rust-clippy#10659 (comment).

This adds applicable suggestions to the `manual_slice_size_calculation` lint:

```
error: manual slice size calculation
  --> $DIR/manual_slice_size_calculation.rs:11:13
   |
LL |     let _ = s_i32.len() * size_of::<i32>(); // WARNING
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)`
   |
   = note: `-D clippy::manual-slice-size-calculation` implied by `-D warnings`
```

changelog: [`manual_slice_size_calculation`]: add machine applicable suggestion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

3 participants