Skip to content

Commit 5f16909

Browse files
committed
Remove empty-argument optimisation
This doesn't work with getTableUnsafe, as empty arguments are considered closed already. We could argubly special-case the empty args, but the optimisation has very minor benefits, so I don't think worrying about too much. Fixes #2246.
1 parent 00475b9 commit 5f16909

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

projects/core/src/main/java/dan200/computercraft/core/lua/VarargArguments.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,8 @@
2020
final class VarargArguments implements IArguments {
2121
private static final Logger LOG = LoggerFactory.getLogger(VarargArguments.class);
2222

23-
private static final VarargArguments EMPTY = new VarargArguments(Constants.NONE);
2423
private static boolean reportedIllegalGet;
2524

26-
static {
27-
EMPTY.escapes = EMPTY.closed = true;
28-
}
29-
3025
private final Varargs varargs;
3126

3227
private volatile boolean closed;
@@ -51,7 +46,7 @@ private VarargArguments(Varargs varargs, VarargArguments root, int offset) {
5146
}
5247

5348
static VarargArguments of(Varargs values) {
54-
return values == Constants.NONE ? EMPTY : new VarargArguments(values);
49+
return new VarargArguments(values);
5550
}
5651

5752
boolean isClosed() {
@@ -138,9 +133,7 @@ public IArguments drop(int count) {
138133
if (count < 0) throw new IllegalStateException("count cannot be negative");
139134
if (count == 0) return this;
140135

141-
var newArgs = varargs.subargs(count + 1);
142-
if (newArgs == Constants.NONE) return EMPTY;
143-
return new VarargArguments(newArgs, this, count);
136+
return new VarargArguments(varargs.subargs(count + 1), this, count);
144137
}
145138

146139
@Override

0 commit comments

Comments
 (0)