mirror of
https://github.com/apple/pkl.git
synced 2026-09-06 09:57:30 +02:00
Optimize annotations without object bodies (#1843)
This skips some unnecessary steps when evaluating annotations that have no attached object bodies by returning an EmptyObjectLiteralNode instead of a PropertiesLiteralNode
This commit is contained in:
@@ -2224,17 +2224,7 @@ public class AstBuilder extends AbstractAstBuilder<Object> {
|
||||
|
||||
var bodyCtx = annotation.getBody();
|
||||
if (bodyCtx == null) {
|
||||
var currentScope = symbolTable.getCurrentScope();
|
||||
//noinspection ConstantConditions
|
||||
return PropertiesLiteralNodeGen.create(
|
||||
createSourceSection(annotation),
|
||||
language,
|
||||
currentScope.getQualifiedName(),
|
||||
currentScope.isCustomThisScope(),
|
||||
null,
|
||||
new UnresolvedTypeNode[0],
|
||||
EconomicMaps.create(),
|
||||
verifyNode);
|
||||
return EmptyObjectLiteralNodeGen.create(createSourceSection(annotation), verifyNode);
|
||||
}
|
||||
|
||||
return symbolTable.enterAnnotationScope(
|
||||
|
||||
+2
-1
@@ -24,7 +24,7 @@ import org.pkl.core.ast.type.UnresolvedTypeNode;
|
||||
import org.pkl.core.runtime.*;
|
||||
|
||||
public final class CheckIsAnnotationClassNode extends ExpressionNode {
|
||||
@Child private UnresolvedTypeNode unresolvedTypeNode;
|
||||
@Child private @Nullable UnresolvedTypeNode unresolvedTypeNode;
|
||||
@Child private @Nullable TypeNode typeNode;
|
||||
|
||||
public CheckIsAnnotationClassNode(UnresolvedTypeNode unresolvedTypeNode) {
|
||||
@@ -37,6 +37,7 @@ public final class CheckIsAnnotationClassNode extends ExpressionNode {
|
||||
if (typeNode == null) {
|
||||
// invalidation is done by insert()
|
||||
CompilerDirectives.transferToInterpreter();
|
||||
assert unresolvedTypeNode != null;
|
||||
typeNode = insert(unresolvedTypeNode.execute(frame));
|
||||
unresolvedTypeNode = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user