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

Update XMaterial.java #1

Merged
merged 1 commit into from
Jun 18, 2019
Merged

Update XMaterial.java #1

merged 1 commit into from
Jun 18, 2019

Conversation

WI5E
Copy link
Contributor

@WI5E WI5E commented Jun 18, 2019

Code improvements

Code improvements
Copy link
Owner

@CryptoMorin CryptoMorin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Some micro optimizations that I've missed.
But in here:
return mat == null ? null : mat.name().endsWith("S") ? valueOf(name) : mat;
mat will never return null. Is there any reason you added the null check? Or is it just a "just in case" thing?

Also I don't understand the concept of saving enum values().

@CryptoMorin CryptoMorin merged commit 767f7e9 into CryptoMorin:master Jun 18, 2019
@WI5E
Copy link
Contributor Author

WI5E commented Jun 18, 2019

  • mat could potentially return null because XMaterial::requestOldXMaterial has the possibility of returning null
  • When calling Enum#values it will create a new array each time. If you're going to be executing the call multiple times, cache it once and use it.

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