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

Cache PacketType#hashCode #818

Merged
merged 1 commit into from
May 24, 2020
Merged

Conversation

astei
Copy link

@astei astei commented Apr 22, 2020

This should result in a general performance improvement, as PacketType is often used as a map key across ProtocolLib. This primarily will make a difference with large numbers of players or lots of packets being sent by the server.

This should result in a general performance improvement, as PacketType is often used as map keys across ProtocolLib.
@dmulloy2
Copy link
Owner

Not that it makes a whole lot of difference, but any reason for replacing the hashCode implementation entirely instead of just caching the original?

@dmulloy2 dmulloy2 merged commit 944b3f8 into dmulloy2:master May 24, 2020
@astei
Copy link
Author

astei commented May 25, 2020

The replacement implementation is almost equivalent to the original Objects.hash() version, which forwards to Arrays.hashCode(). I used the "recipe" from Effective Java to write this particular hash code function.

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

Successfully merging this pull request may close these issues.

None yet

2 participants