Skip to content

Commit

Permalink
flag expiration scanning optimization
Browse files Browse the repository at this point in the history
don't parse objects that don't need parsing for the initial 'clean' sweep
  • Loading branch information
mcmonkey4eva committed Mar 30, 2022
1 parent 8797acb commit 2163065
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
Expand Up @@ -3,6 +3,7 @@
import com.denizenscript.denizencore.objects.ObjectFetcher;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.MapTag;
import com.denizenscript.denizencore.objects.core.TimeTag;
import com.denizenscript.denizencore.utilities.AsciiMatcher;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.text.StringHolder;
Expand Down Expand Up @@ -87,18 +88,33 @@ public void doTotalClean() {
}
ArrayList<StringHolder> toRemove = new ArrayList<>();
for (Map.Entry<StringHolder, SaveOptimizedFlag> entry : map.entrySet()) {
if (!entry.getValue().canExpire) {
SaveOptimizedFlag val = entry.getValue();
if (!val.canExpire) {
continue;
}
if (isExpired(entry.getValue().getMap().map.get(expirationString))) {
TimeTag expireTime = null;
boolean hasSubMap = false;
if (val.map != null) {
expireTime = (TimeTag) val.map.map.get(expirationString);
hasSubMap = val.map.map.get(valueString).canBeType(MapTag.class);
}
else if (val.string.startsWith("map@")) {
MapTag quickMap = MapTag.valueOf(val.string, CoreUtilities.noDebugContext, false);
ObjectTag time = quickMap.map.get(expirationString);
if (time != null) {
expireTime = TimeTag.valueOf(time.toString(), CoreUtilities.noDebugContext);
}
hasSubMap = quickMap.map.get(valueString).canBeType(MapTag.class);
}
if (isExpired(expireTime)) {
toRemove.add(entry.getKey());
modified = true;
}
else {
ObjectTag subValue = entry.getValue().getMap().map.get(valueString);
else if (hasSubMap) {
ObjectTag subValue = val.getMap().map.get(valueString);
if (subValue instanceof MapTag) {
if (doClean((MapTag) subValue)) {
entry.getValue().string = null;
val.string = null;
modified = true;
}
}
Expand Down
Expand Up @@ -53,6 +53,10 @@ public static String unescapeLegacyEntry(String value) {

@Fetchable("map")
public static MapTag valueOf(String string, TagContext context) {
return valueOf(string, context, true);
}

public static MapTag valueOf(String string, TagContext context, boolean processValues) {
if (string == null) {
return null;
}
Expand Down Expand Up @@ -97,7 +101,9 @@ public static MapTag valueOf(String string, TagContext context) {
}
return null;
}
result.putObject(ObjectFetcher.unescapeProperty(data.get(0)), ObjectFetcher.pickObjectFor(ObjectFetcher.unescapeProperty(data.get(1)), context));
String rawVal = ObjectFetcher.unescapeProperty(data.get(1));
ObjectTag val = processValues ? ObjectFetcher.pickObjectFor(rawVal, context) : new ElementTag(rawVal);
result.putObject(ObjectFetcher.unescapeProperty(data.get(0)), val);
}
return result;
}
Expand Down
Expand Up @@ -84,8 +84,8 @@ public class QueueWordList {
"Paper", "Spigot", "Bukkit", // Server software
"Citizens", "Denizen", "Sentinel", // Plugins
"Aufdemrand", "Jeebiss", "Mcmonkey", "Mergu", "Fortifier", "Fullwall", "Morphan", "Acikek", "Aya", // Dev contributors
"Anthony", "Ricky", // Veterans list
"Behr", "Hydra", "Calico", "Icecapade", "Maxime", "Mwthorn", "Wahrheit", "Zozer", "Xeane", "Jumpsplat", "Inquisitor" // Helpers list
"Anthony", "Ricky", "Xeane", // Veterans list
"Behr", "Hydra", "Calico", "Icecapade", "Maxime", "Mwthorn", "Wahrheit", "Zozer", "Jumpsplat", "Inquisitor" // Helpers list
};

public static final String[] donorList = new String[] {
Expand Down

0 comments on commit 2163065

Please sign in to comment.