Eval: Only need to cast AST once

This commit is contained in:
Riyyi
2023-04-10 22:06:36 +02:00
parent 2b260d7b43
commit c279f9111e
+5 -8
View File
@@ -62,20 +62,17 @@ ValuePtr Eval::evalImpl()
return evalAst(ast, env); return evalAst(ast, env);
} }
auto list = std::static_pointer_cast<List>(ast);
if (list->empty()) {
return ast;
}
ast = macroExpand(ast, env); ast = macroExpand(ast, env);
if (!is<List>(ast.get())) { if (!is<List>(ast.get())) {
return evalAst(ast, env); return evalAst(ast, env);
} }
// Macro-expand modifies `ast', so get the new list auto list = std::static_pointer_cast<List>(ast);
list = std::static_pointer_cast<List>(ast);
if (list->empty()) {
return ast;
}
// Special forms // Special forms
auto nodes = list->nodes(); auto nodes = list->nodes();