Skip to content

Commit 6ed522b

Browse files
committed
Store return type in ExprChangeValue to optimize getReturnType method
1 parent 24bed03 commit 6ed522b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main/java/org/skriptlang/reflect/syntax/custom/expression/elements/ExprChangeValue.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static void register(SyntaxRegistry registry) {
2525

2626
private boolean plural;
2727
private Class<?>[] types;
28+
private Class<?> returnType;
2829

2930
@Override
3031
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
@@ -35,6 +36,7 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
3536
this.plural = parseResult.hasTag("s");
3637
ChangerData data = structure.changerData();
3738
this.types = data.acceptedClasses();
39+
this.returnType = Utils.getSuperType(types);
3840
if (!data.testPlurality(plural)) {
3941
Skript.error(plural
4042
? "The changed value may only be a single value"
@@ -58,7 +60,7 @@ public boolean isSingle() {
5860

5961
@Override
6062
public Class<?> getReturnType() {
61-
return Utils.getSuperType(types);
63+
return returnType;
6264
}
6365

6466
@Override

0 commit comments

Comments
 (0)