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

remove redundant boxing and casting #51

Merged

Conversation

Minimaximize
Copy link
Contributor

Removed array instantiation where parameters could be accepted as VArgs
callbackClass.getMethod(callbackMethod, new Class[] { File.class }); =>
callbackClass.getMethod(callbackMethod, File.class);

Remove redundant unboxing where appropriate
(scale instanceof Integer && ((Integer)scale).intValue() == 2) =>
(scale instanceof Integer && (Integer) scale == 2)
In this case scale will automaticaly be unboxed to it's int value

Replace protected void handleMethods(String methodName) and
protected void handleMethods(String methodName, Object[] args)
with
protected void handleMethods(String methodName, Object...args)
as it handles both cases

Remove redundant extends Object clause from type wildcards
List<Disposable> reachableWeakReferences => List> reachableWeakReferences

@@ -1469,7 +1469,7 @@ public int createShader(int type) {

@Override
public void shaderSource(int shader, String source) {
gl2.glShaderSource(shader, 1, new String[] { source }, (int[]) null, 0);
gl2.glShaderSource(shader, 1, new String[] { source }, null, 0);
Copy link
Owner

Choose a reason for hiding this comment

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

Have you tested this? This would have been written the original way due to a compiler error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was able to compile without issue, and in all of my tests, the results were the same 👍

Feels kinda like it shouldn't be allowed, but while the individual elements of a primitive array aren't nullable, arrays are. So null is a perfectly legal value here.

@benfry benfry merged commit 4a6cdf5 into benfry:master Jan 20, 2020
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants