Feuermagier/autograder

Improve performance of `SpoonUtil.resolveConstant`

Luro02 opened this issue · 2 comments

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.

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

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.