Skip to content

Commit

Permalink
clues: remove unnecessary item array copy
Browse files Browse the repository at this point in the history
The array returned by getItems() is always a new array and so does not require copying
  • Loading branch information
Adam- committed Nov 12, 2021
1 parent 40cc117 commit 706b9bd
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,22 +358,22 @@ else if (event.getMenuOption().equals("Search") && clue instanceof EmoteClue)
@Subscribe
public void onItemContainerChanged(final ItemContainerChanged event)
{
if (event.getItemContainer() == client.getItemContainer(InventoryID.EQUIPMENT))
if (event.getContainerId() == InventoryID.EQUIPMENT.getId())
{
equippedItems = event.getItemContainer().getItems();
return;
}

if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY))
if (event.getContainerId() != InventoryID.INVENTORY.getId())
{
return;
}

inventoryItems = event.getItemContainer().getItems();

// Add runes from rune pouch to inventoryItems
if (event.getItemContainer().contains(ItemID.RUNE_POUCH) || event.getItemContainer().contains(ItemID.RUNE_POUCH_L))
{
// Clone the array so changes aren't passed back to the event.
inventoryItems = event.getItemContainer().getItems().clone();

List<Item> runePouchContents = getRunepouchContents();

if (!runePouchContents.isEmpty())
Expand All @@ -395,10 +395,6 @@ public void onItemContainerChanged(final ItemContainerChanged event)
inventoryItems = ArrayUtils.addAll(inventoryItems, runePouchContents.toArray(new Item[0]));
}
}
else
{
inventoryItems = event.getItemContainer().getItems();
}

// Check if item was removed from inventory
if (clue != null && clueItemId != null)
Expand Down Expand Up @@ -432,7 +428,7 @@ public void onItemContainerChanged(final ItemContainerChanged event)

private List<Item> getRunepouchContents()
{
List<Item> items = new ArrayList<>();
List<Item> items = new ArrayList<>(RUNEPOUCH_AMOUNT_VARBITS.length);
for (int i = 0; i < RUNEPOUCH_AMOUNT_VARBITS.length; i++)
{
int amount = client.getVar(RUNEPOUCH_AMOUNT_VARBITS[i]);
Expand Down

0 comments on commit 706b9bd

Please sign in to comment.