mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	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.
This commit is contained in:
		| @@ -20,13 +20,8 @@ import static org.squiddev.cobalt.Constants.NAME; | |||||||
| final class VarargArguments implements IArguments { | final class VarargArguments implements IArguments { | ||||||
|     private static final Logger LOG = LoggerFactory.getLogger(VarargArguments.class); |     private static final Logger LOG = LoggerFactory.getLogger(VarargArguments.class); | ||||||
| 
 | 
 | ||||||
|     private static final VarargArguments EMPTY = new VarargArguments(Constants.NONE); |  | ||||||
|     private static boolean reportedIllegalGet; |     private static boolean reportedIllegalGet; | ||||||
| 
 | 
 | ||||||
|     static { |  | ||||||
|         EMPTY.escapes = EMPTY.closed = true; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     private final Varargs varargs; |     private final Varargs varargs; | ||||||
| 
 | 
 | ||||||
|     private volatile boolean closed; |     private volatile boolean closed; | ||||||
| @@ -51,7 +46,7 @@ final class VarargArguments implements IArguments { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     static VarargArguments of(Varargs values) { |     static VarargArguments of(Varargs values) { | ||||||
|         return values == Constants.NONE ? EMPTY : new VarargArguments(values); |         return new VarargArguments(values); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     boolean isClosed() { |     boolean isClosed() { | ||||||
| @@ -138,9 +133,7 @@ final class VarargArguments implements IArguments { | |||||||
|         if (count < 0) throw new IllegalStateException("count cannot be negative"); |         if (count < 0) throw new IllegalStateException("count cannot be negative"); | ||||||
|         if (count == 0) return this; |         if (count == 0) return this; | ||||||
| 
 | 
 | ||||||
|         var newArgs = varargs.subargs(count + 1); |         return new VarargArguments(varargs.subargs(count + 1), this, count); | ||||||
|         if (newArgs == Constants.NONE) return EMPTY; |  | ||||||
|         return new VarargArguments(newArgs, this, count); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates