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:
Ursprung
c6518a9243
Commit
9cdac001e3
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren