Feuermagier / autograder

Automatic grading of student's Java code
MIT License
13 stars 7 forks source link

Improve performance of `SpoonUtil.resolveConstant` #573

Open Luro02 opened 1 month ago

Luro02 commented 1 month ago

Description

The current implementation is unnecessarily slow, because of redundant clones performed by the Evaluator. The clones are necessary for some Fold, because it would otherwise invalidate the model, but for looking up if a variable has a constant value like ctVariableReference.getDeclaration().getInitExpression() instanceof CtLiteral<?> ctLiteral, we can be a lot more conservative with cloning or skip it all together.

Luro02 commented 1 month ago

Another idea was to clone them lazily like a clone on write, but not sure if that would be possible.

Luro02 commented 3 weeks ago

The lazy cloning sounds like a nice idea but seems impossible to implement.

This would make it harder to implement Fold, but might solve the issue: The Fold impls will be responsible for cloning.