Skip to content

Commit 7893dbf

Browse files
committed
Use cached instanceof implementation in IVar creation
Significantly increases runtime performance of typed code. Runtime of a MethodScript program that computes the CRC32 of a size 250000 byte_array was reduced from 24.5 seconds to 4 seconds.
1 parent 0c54ffd commit 7893dbf

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/java/com/laytonsmith/core/constructs/IVariable.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ public IVariable(CClassType type, String name, Mixed value, Target t, Environmen
4949
if(value instanceof CVoid) {
5050
throw new CRECastException("Void may not be assigned to a variable", t);
5151
}
52-
if(!type.equals(Auto.TYPE) && !(value instanceof CNull)) {
53-
if(!InstanceofUtil.isInstanceof(value, type, env)) {
54-
throw new CRECastException(name + " is of type " + type.val() + ", but a value of type "
55-
+ value.typeof() + " was assigned to it.", t);
56-
}
52+
if(!InstanceofUtil.isInstanceof(value.typeof(), type, env)) {
53+
throw new CRECastException(name + " is of type " + type.val() + ", but a value of type "
54+
+ value.typeof() + " was assigned to it.", t);
5755
}
5856
this.type = type;
5957
this.varValue = value;

0 commit comments

Comments
 (0)