From 5ed5ac82916c26fd1410b61d43e7e1a77ab9d065 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 1 Mar 2018 18:49:36 +0100 Subject: [PATCH] Minor, use stdlib instead of ifEmpty --- .../serialization/deserialization/protoTypeTableUtil.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/protoTypeTableUtil.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/protoTypeTableUtil.kt index cb85a54266a..064f3252cd2 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/protoTypeTableUtil.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/protoTypeTableUtil.kt @@ -17,10 +17,9 @@ package org.jetbrains.kotlin.serialization.deserialization import org.jetbrains.kotlin.metadata.ProtoBuf -import org.jetbrains.kotlin.utils.ifEmpty fun ProtoBuf.Class.supertypes(typeTable: TypeTable): List { - return supertypeList.ifEmpty { supertypeIdList.map { typeTable[it] } } + return supertypeList.takeIf(Collection<*>::isNotEmpty) ?: supertypeIdList.map { typeTable[it] } } fun ProtoBuf.Type.Argument.type(typeTable: TypeTable): ProtoBuf.Type? { @@ -40,7 +39,7 @@ fun ProtoBuf.Type.flexibleUpperBound(typeTable: TypeTable): ProtoBuf.Type? { } fun ProtoBuf.TypeParameter.upperBounds(typeTable: TypeTable): List { - return upperBoundList.ifEmpty { upperBoundIdList.map { typeTable[it] } } + return upperBoundList.takeIf(Collection<*>::isNotEmpty) ?: upperBoundIdList.map { typeTable[it] } } fun ProtoBuf.Function.returnType(typeTable: TypeTable): ProtoBuf.Type { @@ -102,4 +101,4 @@ fun ProtoBuf.TypeAlias.underlyingType(typeTable: TypeTable): ProtoBuf.Type = if (hasUnderlyingTypeId()) typeTable[underlyingTypeId] else underlyingType fun ProtoBuf.TypeAlias.expandedType(typeTable: TypeTable): ProtoBuf.Type = - if (hasExpandedTypeId()) typeTable[expandedTypeId] else expandedType \ No newline at end of file + if (hasExpandedTypeId()) typeTable[expandedTypeId] else expandedType