mirror of
https://github.com/apple/pkl.git
synced 2026-09-09 19:31:51 +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();
|
var bodyCtx = annotation.getBody();
|
||||||
if (bodyCtx == null) {
|
if (bodyCtx == null) {
|
||||||
var currentScope = symbolTable.getCurrentScope();
|
return EmptyObjectLiteralNodeGen.create(createSourceSection(annotation), verifyNode);
|
||||||
//noinspection ConstantConditions
|
|
||||||
return PropertiesLiteralNodeGen.create(
|
|
||||||
createSourceSection(annotation),
|
|
||||||
language,
|
|
||||||
currentScope.getQualifiedName(),
|
|
||||||
currentScope.isCustomThisScope(),
|
|
||||||
null,
|
|
||||||
new UnresolvedTypeNode[0],
|
|
||||||
EconomicMaps.create(),
|
|
||||||
verifyNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return symbolTable.enterAnnotationScope(
|
return symbolTable.enterAnnotationScope(
|
||||||
|
|||||||
+2
-1
@@ -24,7 +24,7 @@ import org.pkl.core.ast.type.UnresolvedTypeNode;
|
|||||||
import org.pkl.core.runtime.*;
|
import org.pkl.core.runtime.*;
|
||||||
|
|
||||||
public final class CheckIsAnnotationClassNode extends ExpressionNode {
|
public final class CheckIsAnnotationClassNode extends ExpressionNode {
|
||||||
@Child private UnresolvedTypeNode unresolvedTypeNode;
|
@Child private @Nullable UnresolvedTypeNode unresolvedTypeNode;
|
||||||
@Child private @Nullable TypeNode typeNode;
|
@Child private @Nullable TypeNode typeNode;
|
||||||
|
|
||||||
public CheckIsAnnotationClassNode(UnresolvedTypeNode unresolvedTypeNode) {
|
public CheckIsAnnotationClassNode(UnresolvedTypeNode unresolvedTypeNode) {
|
||||||
@@ -37,6 +37,7 @@ public final class CheckIsAnnotationClassNode extends ExpressionNode {
|
|||||||
if (typeNode == null) {
|
if (typeNode == null) {
|
||||||
// invalidation is done by insert()
|
// invalidation is done by insert()
|
||||||
CompilerDirectives.transferToInterpreter();
|
CompilerDirectives.transferToInterpreter();
|
||||||
|
assert unresolvedTypeNode != null;
|
||||||
typeNode = insert(unresolvedTypeNode.execute(frame));
|
typeNode = insert(unresolvedTypeNode.execute(frame));
|
||||||
unresolvedTypeNode = null;
|
unresolvedTypeNode = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user