From 706b9bdba097ca7bc1967d50f1fd7142efe54a7a Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 12 Nov 2021 09:17:13 -0500 Subject: [PATCH] clues: remove unnecessary item array copy The array returned by getItems() is always a new array and so does not require copying --- .../plugins/cluescrolls/ClueScrollPlugin.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index 3136d3b9541..ac333a0e6b5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -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 runePouchContents = getRunepouchContents(); if (!runePouchContents.isEmpty()) @@ -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) @@ -432,7 +428,7 @@ public void onItemContainerChanged(final ItemContainerChanged event) private List getRunepouchContents() { - List items = new ArrayList<>(); + List 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]);