Skip to content

Commit

Permalink
reduce number of times resolving parameter types in an extreme case.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 612562471
  • Loading branch information
wanyingd1996 authored and Dagger Team committed Mar 4, 2024
1 parent 1bbd7db commit 922ff50
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions java/dagger/internal/codegen/xprocessing/XElements.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,22 @@ public static String toStableString(XElement element) {
return asTypeElement(element).getQualifiedName();
} else if (isExecutable(element)) {
XExecutableElement executable = asExecutable(element);
// TODO(b/318709946) resolving ksp types can be expensive, therefore we should avoid it
// here for extreme cases until ksp improved the performance.
boolean tooManyParameters =
getProcessingEnv(element).getBackend().equals(XProcessingEnv.Backend.KSP)
&& executable.getParameters().size() > 10;
return String.format(
"%s(%s)",
getSimpleName(
isConstructor(element)
? asConstructor(element).getEnclosingElement()
: executable),
executable.getParameters().stream()
.map(XExecutableParameterElement::getType)
.map(XTypes::toStableString)
.collect(joining(",")));
isConstructor(element) ? asConstructor(element).getEnclosingElement() : executable),
(tooManyParameters
? executable.getParameters().stream().limit(10)
: executable.getParameters().stream()
.map(XExecutableParameterElement::getType)
.map(XTypes::toStableString)
.collect(joining(",")))
+ (tooManyParameters ? ", ..." : ""));
} else if (isEnumEntry(element)
|| isField(element)
|| isMethodParameter(element)
Expand Down

0 comments on commit 922ff50

Please sign in to comment.