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

Use ConcurrentHashMap.newKeySet() as newConcurrentHashSet #3181

Open
turbanoff opened this issue Jun 14, 2018 · 1 comment
Open

Use ConcurrentHashMap.newKeySet() as newConcurrentHashSet #3181

turbanoff opened this issue Jun 14, 2018 · 1 comment

Comments

@turbanoff
Copy link
Contributor

turbanoff commented Jun 14, 2018

Method ConcurrentHashMap.newKeySet() was introduced in java 8.
It can be used to create concurrent hash set implementation. It can be faster that Collections.newSetFromMap as it removes one indirection level - https://stackoverflow.com/questions/32054517/concurrenthashmap-newkeyset-vs-collections-newsetfrommap

@cgdecker
Copy link
Member

I think that the advantages of using newKeySet() are likely extremely minimal, and as such it's not worth introducing an additional diff between the JRE and Android flavors of Guava for this. That said, I could definitely see doing this at whatever point in the future we can use Java 8 APIs everywhere in Guava, so I'm leaving this open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants