Skip to content

Commit d30e319

Browse files
committed
Change Procedure instanceof check to cached variant
Improves runtime performance of procedure calls where the procedure parameters or return value are explicitly provided in user code.
1 parent 0dcb836 commit d30e319

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/laytonsmith/core/Procedure.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ public Mixed execute(List<Mixed> args, Environment oldEnv, Target t) {
239239
throw new CRECastException("Procedure \"" + name + "\" expects a value of type "
240240
+ var.getDefinedType().val() + " in argument " + (varInd + 1) + ", but"
241241
+ " a void value was found instead.", c.getTarget());
242-
} else if(!(c instanceof CVoid) && c instanceof CNull || var.getDefinedType().equals(Auto.TYPE)
243-
|| InstanceofUtil.isInstanceof(c, var.getDefinedType(), env)) {
242+
} else if((!(c instanceof CVoid) && c instanceof CNull) || var.getDefinedType().equals(Auto.TYPE)
243+
|| InstanceofUtil.isInstanceof(c.typeof(), var.getDefinedType(), env)) {
244244
if(isVarArg) {
245245
vararg.push(c, t);
246246
} else {
@@ -291,7 +291,7 @@ public Mixed execute(List<Mixed> args, Environment oldEnv, Target t) {
291291
}
292292
if(returnType.equals(CVoid.TYPE) != ret.equals(CVoid.VOID)
293293
|| !ret.equals(CNull.NULL) && !ret.equals(CVoid.VOID)
294-
&& !InstanceofUtil.isInstanceof(ret, returnType, env)) {
294+
&& !InstanceofUtil.isInstanceof(ret.typeof(), returnType, env)) {
295295
throw new CRECastException("Expected procedure \"" + name + "\" to return a value of type "
296296
+ returnType.val() + " but a value of type " + ret.typeof() + " was returned instead",
297297
ret.getTarget());

0 commit comments

Comments
 (0)