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

Optimize Clone implementation #146

Merged
merged 3 commits into from Mar 16, 2020
Merged

Optimize Clone implementation #146

merged 3 commits into from Mar 16, 2020

Conversation

@Amanieu
Copy link
Collaborator

Amanieu commented Mar 16, 2020

Two major changes:

  • clone_from is now implemented which can be used to skip memory allocation if the existing HashMap already has enough capacity.
  • [nightly] Specialization is used to optimize cloning when T: Copy into a simple memory copy.
  • [nightly] Specialization is used to reuse the existing capacity of a HashMap when clone_from is used. Specialization is needed because the Clone impl on HashMap is missing K: Hash + Eq, S: BuildHasher.

Fixes #112

@Amanieu Amanieu force-pushed the Amanieu:clone_from branch 3 times, most recently from 83de957 to c3396c0 Mar 16, 2020
@Amanieu Amanieu force-pushed the Amanieu:clone_from branch 2 times, most recently from cb23a71 to 81b5f6e Mar 16, 2020
@Amanieu Amanieu force-pushed the Amanieu:clone_from branch from 81b5f6e to c9b320e Mar 16, 2020
@Amanieu Amanieu changed the title Implement clone_from for HashMap Optimize Clone implementation Mar 16, 2020
@Amanieu

This comment has been minimized.

Copy link
Collaborator Author

Amanieu commented Mar 16, 2020

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 16, 2020

📌 Commit c9b320e has been approved by Amanieu

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 16, 2020

⌛️ Testing commit c9b320e with merge 108822c...

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 16, 2020

☀️ Test successful - checks-travis
Approved by: Amanieu
Pushing 108822c to master...

@bors bors merged commit 108822c into rust-lang:master Mar 16, 2020
2 checks passed
2 checks passed
Travis CI - Pull Request Build Passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.