Merge pull request #800 from Abextm/allocation-opimization
Allocation optimization
This commit is contained in:
@@ -39,6 +39,8 @@ import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
class BlastFurnaceCofferOverlay extends Overlay
|
||||
{
|
||||
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance();
|
||||
|
||||
private final Client client;
|
||||
private final BlastFurnacePlugin plugin;
|
||||
private final PanelComponent panelComponent = new PanelComponent();
|
||||
@@ -69,7 +71,7 @@ class BlastFurnaceCofferOverlay extends Overlay
|
||||
|
||||
panelComponent.getLines().add(new PanelComponent.Line(
|
||||
"Coffer:",
|
||||
NumberFormat.getInstance().format(client.getSetting(BLAST_FURNACE_COFFER)) + " gp"
|
||||
NUMBER_FORMATTER.format(client.getSetting(BLAST_FURNACE_COFFER)) + " gp"
|
||||
));
|
||||
}
|
||||
return panelComponent.render(graphics, parent);
|
||||
|
||||
@@ -68,6 +68,8 @@ public class HiscorePanel extends PluginPanel
|
||||
private static final String SKILL_NAME = "SKILL_NAME";
|
||||
private static final String SKILL = "SKILL";
|
||||
|
||||
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance();
|
||||
|
||||
private static final HiscoreSkill[] SKILL_PANEL_ORDER = new HiscoreSkill[]
|
||||
{
|
||||
ATTACK, HITPOINTS, MINING,
|
||||
@@ -255,8 +257,6 @@ public class HiscorePanel extends PluginPanel
|
||||
return;
|
||||
}
|
||||
|
||||
NumberFormat formatter = NumberFormat.getInstance();
|
||||
|
||||
String text;
|
||||
switch (skillName)
|
||||
{
|
||||
@@ -272,8 +272,8 @@ public class HiscorePanel extends PluginPanel
|
||||
result.getPrayer().getLevel()
|
||||
);
|
||||
text = "Skill: Combat" + System.lineSeparator()
|
||||
+ "Exact Combat Level: " + formatter.format(combatLevel) + System.lineSeparator()
|
||||
+ "Experience: " + formatter.format(result.getAttack().getExperience()
|
||||
+ "Exact Combat Level: " + NUMBER_FORMATTER.format(combatLevel) + System.lineSeparator()
|
||||
+ "Experience: " + NUMBER_FORMATTER.format(result.getAttack().getExperience()
|
||||
+ result.getStrength().getExperience() + result.getDefence().getExperience()
|
||||
+ result.getHitpoints().getExperience() + result.getMagic().getExperience()
|
||||
+ result.getRanged().getExperience() + result.getPrayer().getExperience());
|
||||
@@ -281,28 +281,28 @@ public class HiscorePanel extends PluginPanel
|
||||
}
|
||||
case "Clue Scrolls (all)":
|
||||
{
|
||||
String rank = (result.getClueScrollAll().getRank() == -1) ? "Unranked" : formatter.format(result.getClueScrollAll().getRank());
|
||||
String rank = (result.getClueScrollAll().getRank() == -1) ? "Unranked" : NUMBER_FORMATTER.format(result.getClueScrollAll().getRank());
|
||||
text = "Total Clue Scrolls Completed" + System.lineSeparator()
|
||||
+ "Rank: " + rank;
|
||||
break;
|
||||
}
|
||||
case "Bounty Hunter - Rogue":
|
||||
{
|
||||
String rank = (result.getBountyHunterRogue().getRank() == -1) ? "Unranked" : formatter.format(result.getBountyHunterRogue().getRank());
|
||||
String rank = (result.getBountyHunterRogue().getRank() == -1) ? "Unranked" : NUMBER_FORMATTER.format(result.getBountyHunterRogue().getRank());
|
||||
text = "Bounty Hunter - Rogue Kills" + System.lineSeparator()
|
||||
+ "Rank: " + rank;
|
||||
break;
|
||||
}
|
||||
case "Bounty Hunter - Hunter":
|
||||
{
|
||||
String rank = (result.getBountyHunterHunter().getRank() == -1) ? "Unranked" : formatter.format(result.getBountyHunterHunter().getRank());
|
||||
String rank = (result.getBountyHunterHunter().getRank() == -1) ? "Unranked" : NUMBER_FORMATTER.format(result.getBountyHunterHunter().getRank());
|
||||
text = "Bounty Hunter - Hunter Kills" + System.lineSeparator()
|
||||
+ "Rank: " + rank;
|
||||
break;
|
||||
}
|
||||
case "Last Man Standing":
|
||||
{
|
||||
String rank = (result.getLastManStanding().getRank() == -1) ? "Unranked" : formatter.format(result.getLastManStanding().getRank());
|
||||
String rank = (result.getLastManStanding().getRank() == -1) ? "Unranked" : NUMBER_FORMATTER.format(result.getLastManStanding().getRank());
|
||||
text = "Last Man Standing" + System.lineSeparator()
|
||||
+ "Rank: " + rank;
|
||||
break;
|
||||
@@ -310,8 +310,8 @@ public class HiscorePanel extends PluginPanel
|
||||
default:
|
||||
{
|
||||
Skill requestedSkill = result.getSkill(skill);
|
||||
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : formatter.format(requestedSkill.getRank());
|
||||
String exp = (requestedSkill.getRank() == -1) ? "Unranked" : formatter.format(requestedSkill.getExperience());
|
||||
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : NUMBER_FORMATTER.format(requestedSkill.getRank());
|
||||
String exp = (requestedSkill.getRank() == -1) ? "Unranked" : NUMBER_FORMATTER.format(requestedSkill.getExperience());
|
||||
text = "Skill: " + skillName + System.lineSeparator()
|
||||
+ "Rank: " + rank + System.lineSeparator()
|
||||
+ "Experience: " + exp;
|
||||
|
||||
@@ -45,6 +45,8 @@ import net.runelite.client.ui.PluginPanel;
|
||||
@Slf4j
|
||||
class XpPanel extends PluginPanel
|
||||
{
|
||||
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance();
|
||||
|
||||
private final Map<Skill, XpInfoBox> infoBoxes = new HashMap<>();
|
||||
private final JLabel totalXpGained = new JLabel();
|
||||
private final JLabel totalXpHr = new JLabel();
|
||||
@@ -139,7 +141,6 @@ class XpPanel extends PluginPanel
|
||||
|
||||
static String formatLine(double number, String description)
|
||||
{
|
||||
|
||||
return NumberFormat.getInstance().format(number) + " " + description;
|
||||
return NUMBER_FORMATTER.format(number) + " " + description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public abstract class RSHashTableMixin implements RSHashTable
|
||||
@Override
|
||||
public Collection<Node> getNodes()
|
||||
{
|
||||
// Copied in RSWidgetMixin.getParentId to reduce allocations
|
||||
List<Node> nodes = new ArrayList<Node>();
|
||||
|
||||
RSNode[] buckets = getBuckets();
|
||||
|
||||
@@ -43,6 +43,7 @@ import net.runelite.api.widgets.WidgetItem;
|
||||
import static net.runelite.client.callback.Hooks.eventBus;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSHashTable;
|
||||
import net.runelite.rs.api.RSNode;
|
||||
import net.runelite.rs.api.RSWidget;
|
||||
|
||||
@Mixin(RSWidget.class)
|
||||
@@ -76,18 +77,27 @@ public abstract class RSWidgetMixin implements RSWidget
|
||||
return parentId;
|
||||
}
|
||||
|
||||
int i = TO_GROUP(getId());
|
||||
int groupId = TO_GROUP(getId());
|
||||
RSHashTable componentTable = client.getComponentTable();
|
||||
for (Node node : componentTable.getNodes())
|
||||
RSNode[] buckets = componentTable.getBuckets();
|
||||
for (int i = 0; i < buckets.length; ++i)
|
||||
{
|
||||
WidgetNode wn = (WidgetNode) node;
|
||||
Node node = buckets[i];
|
||||
|
||||
if (i == wn.getId())
|
||||
// It looks like the first node in the bucket is always
|
||||
// a sentinel
|
||||
Node cur = node.getNext();
|
||||
while (cur != node)
|
||||
{
|
||||
return (int) wn.getHash();
|
||||
WidgetNode wn = (WidgetNode) cur;
|
||||
|
||||
if (groupId == wn.getId())
|
||||
{
|
||||
return (int) wn.getHash();
|
||||
}
|
||||
cur = cur.getNext();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user