Don't write unnecessary information to ValueParameter proto

Flags can have a default value and the index can be trivially computed almost
all the time
This commit is contained in:
Alexander Udalov
2015-09-24 12:37:45 +03:00
parent ccf72668e0
commit 542bfab96f
9 changed files with 35 additions and 22 deletions
@@ -268,7 +268,9 @@ public class FunctionCodegen {
if (kind == JvmMethodParameterKind.VALUE) {
ValueParameterDescriptor parameter = iterator.next();
v.getSerializationBindings().put(INDEX_FOR_VALUE_PARAMETER, parameter, i);
if (parameter.getIndex() != i) {
v.getSerializationBindings().put(INDEX_FOR_VALUE_PARAMETER, parameter, i);
}
AnnotationCodegen annotationCodegen = AnnotationCodegen.forParameter(i, mv, typeMapper);
if (functionDescriptor instanceof PropertySetterDescriptor) {
@@ -284,7 +284,10 @@ public class DescriptorSerializer {
private ProtoBuf.Callable.ValueParameter.Builder valueParameter(@NotNull ValueParameterDescriptor descriptor) {
ProtoBuf.Callable.ValueParameter.Builder builder = ProtoBuf.Callable.ValueParameter.newBuilder();
builder.setFlags(Flags.getValueParameterFlags(hasAnnotations(descriptor), descriptor.declaresDefaultValue()));
int flags = Flags.getValueParameterFlags(hasAnnotations(descriptor), descriptor.declaresDefaultValue());
if (flags != 0) {
builder.setFlags(flags);
}
builder.setName(getSimpleNameIndex(descriptor.getName()));