3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-10 05:20:04 +01:00

Added a megabuf function to the expression parser, which works like gmegabuf, except that there is one buffer per Expression instance.

Dieser Commit ist enthalten in:
TomyLobo 2011-11-30 05:27:11 +01:00
Ursprung c6518a9243
Commit 9cdac001e3
2 geänderte Dateien mit 23 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -63,6 +63,7 @@ public class Expression {
private final Map<String, RValue> variables = new HashMap<String, RValue>();
private final String[] variableNames;
private RValue root;
private final Map<Integer, double[]> megabuf = new HashMap<Integer, double[]>();
public static Expression compile(String expression, String... variableNames) throws ExpressionException {
return new Expression(expression, variableNames);
@ -151,4 +152,8 @@ public class Expression {
instance.set(null);
}
}
public Map<Integer, double[]> getMegabuf() {
return megabuf;
}
}

Datei anzeigen

@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import com.sk89q.worldedit.expression.Expression;
import com.sk89q.worldedit.expression.runtime.Function.Dynamic;
/**
@ -272,10 +273,10 @@ public final class Functions {
private static final Map<Integer, double[]> gmegabuf = new HashMap<Integer, double[]>();
private static double[] getSubBuffer(Integer key) {
double[] ret = gmegabuf.get(key);
private static double[] getSubBuffer(Map<Integer, double[]> megabuf, Integer key) {
double[] ret = megabuf.get(key);
if (ret == null) {
gmegabuf.put(key, ret = new double[1024]);
megabuf.put(key, ret = new double[1024]);
}
return ret;
}
@ -283,13 +284,25 @@ public final class Functions {
@Dynamic
public static final double gmegabuf(RValue index) throws EvaluationException {
final int intIndex = (int) index.getValue();
return getSubBuffer(intIndex & ~1023)[intIndex & 1023];
return getSubBuffer(gmegabuf, intIndex & ~1023)[intIndex & 1023];
}
@Dynamic
public static final double gmegabuf(RValue index, double value) throws EvaluationException {
final int intIndex = (int) index.getValue();
return getSubBuffer(intIndex & ~1023)[intIndex & 1023] = value;
return getSubBuffer(gmegabuf, intIndex & ~1023)[intIndex & 1023] = value;
}
@Dynamic
public static final double megabuf(RValue index) throws EvaluationException {
final int intIndex = (int) index.getValue();
return getSubBuffer(Expression.getInstance().getMegabuf(), intIndex & ~1023)[intIndex & 1023];
}
@Dynamic
public static final double megabuf(RValue index, double value) throws EvaluationException {
final int intIndex = (int) index.getValue();
return getSubBuffer(Expression.getInstance().getMegabuf(), intIndex & ~1023)[intIndex & 1023] = value;
}