Skip to content

Commit

Permalink
Remove some boxing via Optional in getResultType.
Browse files Browse the repository at this point in the history
Not a big deal, but this is an extra allocation and a bit obfuscated. (I almost want a Klippy for this pattern; I've seen it in readability reviews too...)

PiperOrigin-RevId: 693353388
  • Loading branch information
graememorgan authored and Error Prone Team committed Nov 5, 2024
1 parent b02e05b commit 320f454
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ public static Type getReturnType(ExpressionTree expressionTree) {
*/
public static @Nullable Type getResultType(ExpressionTree expressionTree) {
Type type = ASTHelpers.getType(expressionTree);
return type == null ? null : Optional.ofNullable(type.getReturnType()).orElse(type);
return type == null ? null : (type.getReturnType() == null ? type : type.getReturnType());
}

/**
Expand Down

0 comments on commit 320f454

Please sign in to comment.