Remove unnecessary method in TranslationMap
All it does is translate names to symbols (which is done above, before the rewrite)
and a lookup for each sub-expression, which is already being done by the rewriter as
it walks the tree recursively.
@@ -120,31 +120,11 @@ class TranslationMap
if (expressionToSymbols.containsKey(node)) {
return expressionToSymbols.get(node).toSymbolReference();
}
- else if (expressionToExpressions.containsKey(node)) {
- Expression mapping = getMapping(node);
- mapping = translateNamesToSymbols(mapping);
- return treeRewriter.defaultRewrite(mapping, context);
- }
- else {
- return treeRewriter.defaultRewrite(node, context);
- }
- }
- }, mapped);
- }
- private Expression getMapping(Expression expression)
- {
- if (!expressionToExpressions.containsKey(expression)) {
- return expression;
- }
-
- Expression mapped = expressionToExpressions.get(expression);
- Expression translated = translateNamesToSymbols(mapped);
- if (!translated.equals(expression) && expressionToExpressions.containsKey(translated)) {
- mapped = getMapping(translated);
+ Expression translated = expressionToExpressions.getOrDefault(node, node);
+ return treeRewriter.defaultRewrite(translated, context);
}
-
- return mapped;
+ }, mapped);
}
public void put(Expression expression, Symbol symbol)
