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
@@ -44,6 +44,7 @@ public interface AnnotationAndConstantLoader<A, C, T> {
@NotNull ProtoBuf.Callable callable,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind,
int parameterIndex,
@NotNull ProtoBuf.Callable.ValueParameter proto
);
@@ -208,16 +208,17 @@ public class MemberDeserializer(private val c: DeserializationContext) {
private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List<ValueParameterDescriptor> {
val callableDescriptor = c.containingDeclaration as CallableDescriptor
val containerOfCallable = callableDescriptor.getContainingDeclaration().asProtoContainer()
val containerOfCallable = callableDescriptor.containingDeclaration.asProtoContainer()
return callable.getValueParameterList().mapIndexed { i, proto ->
return callable.valueParameterList.mapIndexed { i, proto ->
val flags = if (proto.hasFlags()) proto.flags else 0
ValueParameterDescriptorImpl(
callableDescriptor, null, i,
containerOfCallable?.let { getParameterAnnotations(it, callable, kind, proto) } ?: Annotations.EMPTY,
c.nameResolver.getName(proto.getName()),
c.typeDeserializer.type(proto.getType()),
Flags.DECLARES_DEFAULT_VALUE.get(proto.getFlags()),
if (proto.hasVarargElementType()) c.typeDeserializer.type(proto.getVarargElementType()) else null,
containerOfCallable?.let { getParameterAnnotations(it, callable, kind, i, proto) } ?: Annotations.EMPTY,
c.nameResolver.getName(proto.name),
c.typeDeserializer.type(proto.type),
Flags.DECLARES_DEFAULT_VALUE.get(flags),
if (proto.hasVarargElementType()) c.typeDeserializer.type(proto.varargElementType) else null,
SourceElement.NO_SOURCE
)
}.toReadOnlyList()
@@ -227,10 +228,13 @@ public class MemberDeserializer(private val c: DeserializationContext) {
container: ProtoContainer,
callable: Callable,
kind: AnnotatedCallableKind,
index: Int,
valueParameter: Callable.ValueParameter
): Annotations {
return DeserializedAnnotations(c.storageManager) {
c.components.annotationAndConstantLoader.loadValueParameterAnnotations(container, callable, c.nameResolver, kind, valueParameter)
c.components.annotationAndConstantLoader.loadValueParameterAnnotations(
container, callable, c.nameResolver, kind, index, valueParameter
)
}
}