Skip to content

Commit

Permalink
Use cached instanceof implementation in IVar creation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Pieter12345 committed Nov 11, 2023
1 parent 0c54ffd commit 7893dbf
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/java/com/laytonsmith/core/constructs/IVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ public IVariable(CClassType type, String name, Mixed value, Target t, Environmen
if(value instanceof CVoid) {
throw new CRECastException("Void may not be assigned to a variable", t);
}
if(!type.equals(Auto.TYPE) && !(value instanceof CNull)) {
if(!InstanceofUtil.isInstanceof(value, type, env)) {
throw new CRECastException(name + " is of type " + type.val() + ", but a value of type "
+ value.typeof() + " was assigned to it.", t);
}
if(!InstanceofUtil.isInstanceof(value.typeof(), type, env)) {
throw new CRECastException(name + " is of type " + type.val() + ", but a value of type "
+ value.typeof() + " was assigned to it.", t);
}
this.type = type;
this.varValue = value;
Expand Down

0 comments on commit 7893dbf

Please sign in to comment.