-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cleanup strange code #2241
base: master
Are you sure you want to change the base?
Cleanup strange code #2241
Conversation
These places should be optimised
@@ -101,18 +101,6 @@ public static void convertRGBEtoFloat2(byte[] rgbe, float[] rgbf){ | |||
rgbf[2] = (B / 256.0f) * e; | |||
} | |||
|
|||
public static void convertRGBEtoFloat3(byte[] rgbe, float[] rgbf){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method cannot be deleted, in order to maintain backwards compatibility.
vertexMap.set(i, i); | ||
indexMap.set(i, i); | ||
vertexMap.add(i, i); | ||
indexMap.add(i, i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be reverted back to set
. add
inserts elements, which I don't think is correct here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The set method does replace one element of the collection with another. However, if an element with the given index does not exist, the method will generate an IndexOutOfBoundExeption error. In the above code, the collection is created before the loop, so it will always be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically add(index,v) is still wrong, the only reason it works is that it is executed in sequence from 0 to n, so i suggest to change it to
vertexMap.add(i);
indexMap.add(i);
without the index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the vCount initializes the capacity, that is indeed the initial size of the internal array, however set will still fail because size() is not == capacity in arraylist . Kinda weird, but that's how it is, it would need a for(0..capacity) vertexMap.add(null)
for set to work as expected
Hi. I simple corrected the oddities in the code.