From 1bf8f2544b04c86d10f684e0a6098953d1e4be00 Mon Sep 17 00:00:00 2001 From: Assaf Date: Tue, 17 Jul 2018 15:47:21 +0300 Subject: [PATCH] Refactor LocatedItems to use the function addItem() instead of initItemsIfNull(). --- .../org/jf/dexlib2/builder/LocatedItems.java | 16 ++++++++-------- 1 file 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 { @Nullable private List items = null; - private void initItemsIfNull() { - if (items == null) { - items = new ArrayList<>(1); - } - } - @Nonnull private List getItems() { if (items == null) { @@ -70,13 +64,19 @@ public abstract class LocatedItems { 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 otherLocatedItems) {