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

Cleanup strange code #2241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

TheLivan
Copy link

@TheLivan TheLivan commented Apr 9, 2024

Hi. I simple corrected the oddities in the code.

@@ -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){
Copy link
Contributor

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);
Copy link
Contributor

@codex128 codex128 Apr 9, 2024

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.

Copy link
Author

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.

Copy link
Member

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

Copy link
Member

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

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.

3 participants