Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private void incrementPosition() {
// not be added
private int[] currentSlab;
private int currentSlabPos;
private int totalSize;

private void allocateSlab() {
currentSlab = new int[currentSlabSize];
Expand Down Expand Up @@ -129,6 +130,7 @@ public void add(int i) {

currentSlab[currentSlabPos] = i;
++currentSlabPos;
++totalSize;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking at the code, totalSize will always be the same as currentSlabSize

}

/**
Expand All @@ -150,11 +152,6 @@ public IntIterator iterator() {
* @return the current size of the list
*/
public int size() {
int size = currentSlabPos;
for (int[] slab : slabs) {
size += slab.length;
}
Comment on lines -154 to -156
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this change is correct. We're returning the slab length, and this one can grow as well (double until MAX_SLAB_SIZE)


return size;
return totalSize;
}
}