Expression parser: Extended the index range of the megabuf function and renamed it to gmegabuf

Dieser Commit ist enthalten in:
TomyLobo 2011-11-22 02:33:01 +01:00
Ursprung c6fee413dc
Commit 5071885d10

Datei anzeigen

@ -262,15 +262,25 @@ public final class Functions {
} }
private static final double[] megabuf = new double[1024]; private static final Map<Integer, double[]> gmegabuf = new HashMap<Integer, double[]>();
@Dynamic private static double[] getSubBuffer(Integer key) {
public static final double megabuf(RValue index) throws EvaluationException { double[] ret = gmegabuf.get(key);
return megabuf[(int) index.getValue()]; if (ret == null) {
gmegabuf.put(key, ret = new double[1024]);
}
return ret;
} }
@Dynamic @Dynamic
public static final double megabuf(RValue index, double value) throws EvaluationException { public static final double gmegabuf(RValue index) throws EvaluationException {
return megabuf[(int) index.getValue()] = value; final int intIndex = (int) index.getValue();
return getSubBuffer(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;
} }
} }