aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf <asafyi@gmail.com>2018-07-17 15:47:21 +0300
committerBen Gruver <bgruv@google.com>2018-08-27 12:59:22 -0700
commit1bf8f2544b04c86d10f684e0a6098953d1e4be00 (patch)
tree566df3b333829f24f2004747db05d63b747c62d7
parentaf8bc1d9cd308e3d4f52330f740725c5c7847f1d (diff)
downloadsmali-1bf8f2544b04c86d10f684e0a6098953d1e4be00.tar.gz
Refactor LocatedItems to use the function addItem() instead of
initItemsIfNull().
-rw-r--r--dexlib2/src/main/java/org/jf/dexlib2/builder/LocatedItems.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/LocatedItems.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/LocatedItems.java
index 261742f9..89f0ac11 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/builder/LocatedItems.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/LocatedItems.java
@@ -13,12 +13,6 @@ public abstract class LocatedItems<T extends ItemWithLocation> {
@Nullable
private List<T> items = null;
- private void initItemsIfNull() {
- if (items == null) {
- items = new ArrayList<>(1);
- }
- }
-
@Nonnull
private List<T> getItems() {
if (items == null) {
@@ -70,13 +64,19 @@ public abstract class LocatedItems<T extends ItemWithLocation> {
throw new IllegalArgumentException(getAddLocatedItemError());
}
item.setLocation(newItemsLocation);
- initItemsIfNull();
- items.add(item);
+ addItem(item);
return true;
}
};
}
+ private void addItem(@Nonnull T item) {
+ if (items == null) {
+ items = new ArrayList<>(1);
+ }
+ items.add(item);
+ }
+
protected abstract String getAddLocatedItemError();
public void mergeItemsIntoNext(@Nonnull MethodLocation nextLocation, LocatedItems<T> otherLocatedItems) {