Skip to content
This repository was archived by the owner on Feb 23, 2018. It is now read-only.

Fix findItemByIndex in case of hash collisions #9

Merged
merged 1 commit into from
Jul 28, 2015
Merged
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
16 changes: 12 additions & 4 deletions src/main/java/scala/tools/asm/ClassWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1747,12 +1747,20 @@ private void put(final Item i) {
}

/**
* Find item that whose index is `index`.
* Returns the item with a specific index.
*
* @param index
* the index of the searched item.
* @return the item with the given index.
*/
public Item findItemByIndex(int index) {
int i = 0;
while (i < items.length && (items[i] == null || items[i].index != index)) i++;
return items[i];
for (Item item : items) {
while (item != null) {
if (item.index == index) return item;
item = item.next;
}
}
return null;
}

/**
Expand Down