private static Serializable _optimizeTree(final CompiledExpression compiled) {
/**
* If there is only one token, and it's an identifier, we can optimize this as an accessor expression.
*/
if (compiled.isSingleNode()) {
ASTNode tk = compiled.getFirstNode();
if (tk.isLiteral() && !tk.isThisVal()) {
return new ExecutableLiteral(tk.getLiteralValue());
}
return tk.canSerializeAccessor() ? new ExecutableAccessorSafe(tk, compiled.getKnownEgressType()) :
new ExecutableAccessor(tk, compiled.getKnownEgressType());
}
return compiled;
}