Compare commits

...
2 Commits
Author SHA1 Message Date
danyadev e774dd5e10 optimize StructureDefinition.addShape (#54)
Before: 161ms of loading time
After: 60.7ms of loading time

An example with Forge of Gods
<img width="1917" height="513" alt="image"
src="https://github.com/user-attachments/assets/61e9b420-7cc2-4e76-89f3-864bd6d7a77f"
/>
<img width="1918" height="490" alt="image"
src="https://github.com/user-attachments/assets/5297956c-41c8-43f7-9451-e29e26609a7e"
/>
2026-03-01 13:03:05 +01:00
Martin Robertz 0866dbee98 fix 2026-01-05 22:05:18 +01:00
2 changed files with 22 additions and 4 deletions

No files matched your search

+1
View File
@@ -6,4 +6,5 @@ dependencies {
testImplementation(platform('org.junit:junit-bom:5.9.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
testRuntimeOnly ('org.junit.platform:junit-platform-launcher')
}
@@ -148,15 +148,32 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
occupiedSpaces.put(name, occupiedSpace);
String built = builder.toString().replaceAll("[\\uA000\\uB000\\uC000]", "");
boolean hasPlus = false;
boolean hasMinus = false;
if (built.contains("+")) {
int write = 0;
for (int read = 0; read < builder.length(); read++) {
char ch = builder.charAt(read);
if (ch == A || ch == B || ch == C) {
continue;
}
if (ch == '+') {
hasPlus = true;
} else if (ch == '-') {
hasMinus = true;
}
if (read != write) builder.setCharAt(write, ch);
write++;
}
builder.setLength(write);
if (hasPlus) {
addElement('+', notAir());
}
if (built.contains("-")) {
if (hasMinus) {
addElement('-', isAir());
}
shapes.put(name, built);
shapes.put(name, builder.toString());
return this;
}