Format nits.

This commit is contained in:
Gary Gregory 2021-08-26 15:57:28 -04:00
parent bfbf729ca7
commit e93e4f2e87
1 changed files with 6 additions and 5 deletions

View File

@ -151,7 +151,7 @@ abstract class MemberUtils {
// "source" and "destination" are the actual and declared args respectively.
float totalCost = 0.0f;
final long normalArgsLen = isVarArgs ? destArgs.length-1 : destArgs.length;
final long normalArgsLen = isVarArgs ? destArgs.length - 1 : destArgs.length;
if (srcArgs.length < normalArgsLen) {
return Float.MAX_VALUE;
}
@ -162,19 +162,20 @@ abstract class MemberUtils {
// When isVarArgs is true, srcArgs and dstArgs may differ in length.
// There are two special cases to consider:
final boolean noVarArgsPassed = srcArgs.length < destArgs.length;
final boolean explicitArrayForVarargs = srcArgs.length == destArgs.length && srcArgs[srcArgs.length-1] != null && srcArgs[srcArgs.length-1].isArray();
final boolean explicitArrayForVarargs = srcArgs.length == destArgs.length && srcArgs[srcArgs.length - 1] != null
&& srcArgs[srcArgs.length - 1].isArray();
final float varArgsCost = 0.001f;
final Class<?> destClass = destArgs[destArgs.length-1].getComponentType();
final Class<?> destClass = destArgs[destArgs.length - 1].getComponentType();
if (noVarArgsPassed) {
// When no varargs passed, the best match is the most generic matching type, not the most specific.
totalCost += getObjectTransformationCost(destClass, Object.class) + varArgsCost;
} else if (explicitArrayForVarargs) {
final Class<?> sourceClass = srcArgs[srcArgs.length-1].getComponentType();
final Class<?> sourceClass = srcArgs[srcArgs.length - 1].getComponentType();
totalCost += getObjectTransformationCost(sourceClass, destClass) + varArgsCost;
} else {
// This is typical varargs case.
for (int i = destArgs.length-1; i < srcArgs.length; i++) {
for (int i = destArgs.length - 1; i < srcArgs.length; i++) {
final Class<?> srcClass = srcArgs[i];
totalCost += getObjectTransformationCost(srcClass, destClass) + varArgsCost;
}