mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Use interned strings when decoding objects/items/npcs
Converts decoded string fields (e.g. name, description, action) to interned strings during decoding to cut down memory usage.
This commit is contained in:
committed by
Gary Tierney
parent
97896a34a4
commit
9446c272f1
@@ -73,9 +73,11 @@ public final class ItemDefinitionDecoder implements Runnable {
|
||||
} else if (opcode == 1) {
|
||||
buffer.getShort();
|
||||
} else if (opcode == 2) {
|
||||
definition.setName(BufferUtil.readString(buffer));
|
||||
String name = BufferUtil.readString(buffer);
|
||||
definition.setName(name.intern());
|
||||
} else if (opcode == 3) {
|
||||
definition.setDescription(BufferUtil.readString(buffer));
|
||||
String description = BufferUtil.readString(buffer);
|
||||
definition.setDescription(description.intern());
|
||||
} else if (opcode >= 4 && opcode <= 8 || opcode == 10) {
|
||||
buffer.getShort();
|
||||
} else if (opcode == 11) {
|
||||
@@ -99,9 +101,10 @@ public final class ItemDefinitionDecoder implements Runnable {
|
||||
if (str.equalsIgnoreCase("hidden")) {
|
||||
str = null;
|
||||
}
|
||||
definition.setGroundAction(opcode - 30, str);
|
||||
definition.setGroundAction(opcode - 30, str.intern());
|
||||
} else if (opcode >= 35 && opcode < 40) {
|
||||
definition.setInventoryAction(opcode - 35, BufferUtil.readString(buffer));
|
||||
String action = BufferUtil.readString(buffer);
|
||||
definition.setInventoryAction(opcode - 35, action.intern());
|
||||
} else if (opcode == 40) {
|
||||
int colourCount = buffer.get() & 0xFF;
|
||||
for (int i = 0; i < colourCount; i++) {
|
||||
|
||||
@@ -80,9 +80,11 @@ public final class NpcDefinitionDecoder implements Runnable {
|
||||
models[index] = buffer.getShort();
|
||||
}
|
||||
} else if (opcode == 2) {
|
||||
definition.setName(BufferUtil.readString(buffer));
|
||||
String name = BufferUtil.readString(buffer);
|
||||
definition.setName(name.intern());
|
||||
} else if (opcode == 3) {
|
||||
definition.setDescription(BufferUtil.readString(buffer));
|
||||
String description = BufferUtil.readString(buffer);
|
||||
definition.setDescription(description.intern());
|
||||
} else if (opcode == 12) {
|
||||
definition.setSize(buffer.get());
|
||||
} else if (opcode == 13) {
|
||||
@@ -98,7 +100,7 @@ public final class NpcDefinitionDecoder implements Runnable {
|
||||
action = null;
|
||||
}
|
||||
|
||||
definition.setInteraction(opcode - 30, action);
|
||||
definition.setInteraction(opcode - 30, action.intern());
|
||||
} else if (opcode == 40) {
|
||||
int length = buffer.get() & 0xFF;
|
||||
int[] originalColours = new int[length];
|
||||
|
||||
@@ -78,9 +78,11 @@ public final class ObjectDefinitionDecoder implements Runnable {
|
||||
data.get();
|
||||
}
|
||||
} else if (opcode == 2) {
|
||||
definition.setName(BufferUtil.readString(data));
|
||||
String name = BufferUtil.readString(data);
|
||||
definition.setName(name.intern());
|
||||
} else if (opcode == 3) {
|
||||
definition.setDescription(BufferUtil.readString(data));
|
||||
String description = BufferUtil.readString(data);
|
||||
definition.setDescription(description.intern());
|
||||
} else if (opcode == 5) {
|
||||
int amount = data.get() & 0xFF;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
@@ -106,7 +108,7 @@ public final class ObjectDefinitionDecoder implements Runnable {
|
||||
actions = new String[10];
|
||||
}
|
||||
String action = BufferUtil.readString(data);
|
||||
actions[opcode - 30] = action;
|
||||
actions[opcode - 30] = action.intern();
|
||||
definition.setMenuActions(actions);
|
||||
} else if (opcode == 39) {
|
||||
data.get();
|
||||
|
||||
Reference in New Issue
Block a user