Skip to content

Cache PacketType#hashCode#818

Merged
dmulloy2 merged 1 commit intodmulloy2:masterfrom
astei:cache-packettype-hashcode
May 24, 2020
Merged

Cache PacketType#hashCode#818
dmulloy2 merged 1 commit intodmulloy2:masterfrom
astei:cache-packettype-hashcode

Conversation

@astei
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
Contributor 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.

2 participants