When interning an item, don't forget to add the item to the items list

git-svn-id: https://smali.googlecode.com/svn/trunk@413 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-08-24 05:47:29 +00:00
parent 7eca83ddb6
commit 3687f27ddd

View File

@ -34,8 +34,6 @@ import org.jf.dexlib.Util.AlignmentUtils;
import java.util.*; import java.util.*;
import junit.framework.Assert;
public abstract class Section<T extends Item> { public abstract class Section<T extends Item> {
/** /**
* A list of the items that this section contains. * A list of the items that this section contains.
@ -90,7 +88,7 @@ public abstract class Section<T extends Item> {
for (int i=0; i < items.size(); i++) { for (int i=0; i < items.size(); i++) {
T item = items.get(i); T item = items.get(i);
Assert.assertTrue("This section contains a null item", item != null); assert item != null;
offset = AlignmentUtils.alignOffset(offset, ItemType.ItemAlignment); offset = AlignmentUtils.alignOffset(offset, ItemType.ItemAlignment);
offset = item.placeAt(offset, i); offset = item.placeAt(offset, i);
} }
@ -179,6 +177,7 @@ public abstract class Section<T extends Item> {
T internedItem = getInternedItem(item); T internedItem = getInternedItem(item);
if (internedItem == null) { if (internedItem == null) {
uniqueItems.put(item, item); uniqueItems.put(item, item);
items.add(item);
return item; return item;
} }
return internedItem; return internedItem;
@ -202,7 +201,7 @@ public abstract class Section<T extends Item> {
private void buildInternedItemMap() { private void buildInternedItemMap() {
uniqueItems = new HashMap<T,T>(); uniqueItems = new HashMap<T,T>();
for (T item: items) { for (T item: items) {
Assert.assertTrue("item shouldn't be null here", item != null); assert item != null;
uniqueItems.put(item, item); uniqueItems.put(item, item);
} }
} }