Skip to content

Commit

Permalink
Trivial refactoring: extract constant
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Jan 18, 2025
1 parent e100ab8 commit 757cc1b
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class StaticTypesLambdaWriter extends LambdaWriter implements AbstractFun

private static final String IS_GENERATED_CONSTRUCTOR = "__IS_GENERATED_CONSTRUCTOR";
private static final String LAMBDA_SHARED_VARIABLES = "__LAMBDA_SHARED_VARIABLES";
private static final String DO_CALL = "doCall";

private final Map<Expression, ClassNode> lambdaClassNodes = new HashMap<>();
private final StaticTypesClosureWriter staticTypesClosureWriter;
Expand All @@ -110,7 +111,7 @@ public void writeLambda(final LambdaExpression expression) {
}

ClassNode lambdaClass = getOrAddLambdaClass(expression, abstractMethod);
MethodNode lambdaMethod = lambdaClass.getMethods("doCall").get(0);
MethodNode lambdaMethod = lambdaClass.getMethods(DO_CALL).get(0);

boolean canDeserialize = controller.getClassNode().hasMethod(createDeserializeLambdaMethodName(lambdaClass), createDeserializeLambdaMethodParams());
if (!canDeserialize) {
Expand Down Expand Up @@ -214,8 +215,8 @@ private String createAbstractMethodDesc(final ClassNode functionalInterface, fin
}

private ClassNode getOrAddLambdaClass(final LambdaExpression expression, final MethodNode abstractMethod) {
return lambdaClassNodes.computeIfAbsent(expression, key -> {
ClassNode lambdaClass = createLambdaClass(expression, ACC_FINAL | ACC_PUBLIC | ACC_STATIC, abstractMethod);
return lambdaClassNodes.computeIfAbsent(expression, expr -> {
ClassNode lambdaClass = createLambdaClass((LambdaExpression) expr, ACC_FINAL | ACC_PUBLIC | ACC_STATIC, abstractMethod);
controller.getAcg().addInnerClass(lambdaClass);
lambdaClass.addInterface(GENERATED_LAMBDA_TYPE);
lambdaClass.putNodeMetaData(StaticCompilationMetadataKeys.STATIC_COMPILE_NODE, Boolean.TRUE);
Expand Down Expand Up @@ -276,7 +277,7 @@ private MethodNode addSyntheticLambdaMethodNode(final LambdaExpression expressio
expression.putNodeMetaData(LAMBDA_SHARED_VARIABLES, localVariableParameters);

MethodNode doCallMethod = lambdaClass.addMethod(
"doCall",
DO_CALL,
ACC_PUBLIC,
abstractMethod.getReturnType(),
parametersWithExactType.clone(),
Expand Down

0 comments on commit 757cc1b

Please sign in to comment.