Migrate compiler and others from sumBy to sumOf

This commit is contained in:
Abduqodiri Qurbonzoda
2021-04-08 03:46:14 +03:00
parent 33b44585c4
commit 19116e5623
11 changed files with 13 additions and 13 deletions
@@ -480,7 +480,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
assert(constantValue is Int) { "Mask should be of Integer type, but " + constantValue }
maskValues.add(constantValue as Int)
if (maskStartIndex == -1) {
maskStartIndex = invocationParamBuilder.listAllParams().sumBy {
maskStartIndex = invocationParamBuilder.listAllParams().sumOf {
if (it is CapturedParamInfo) 0 else it.type.size
}
}
@@ -1086,7 +1086,7 @@ class MethodInliner(
"Number of expected and actual parameters should be equal, but ${actualParams.size} != ${directOrder.size}!"
}
var currentShift = shift + directOrder.sumBy { it.size }
var currentShift = shift + directOrder.sumOf { it.size }
val safeToUseArgumentKotlinType =
directOrder.size == directOrderOfArguments.size && directOrderOfArguments.size == directOrderOfInvokeParameters.size
@@ -24,13 +24,13 @@ class Parameters(val parameters: List<ParameterInfo>) : Iterable<ParameterInfo>
private val actualDeclShifts: Array<ParameterInfo?>
private val paramToDeclByteCodeIndex: HashMap<ParameterInfo, Int> = hashMapOf()
val argsSizeOnStack = parameters.sumBy { it.type.size }
val argsSizeOnStack = parameters.sumOf { it.type.size }
val realParametersSizeOnStack: Int
get() = argsSizeOnStack - capturedParametersSizeOnStack
val capturedParametersSizeOnStack by lazy {
captured.sumBy { it.type.size }
captured.sumOf { it.type.size }
}
val captured by lazy {
@@ -109,7 +109,7 @@ private fun ConeKotlinType.enhanceConeKotlinType(
}
private fun ConeKotlinType.subtreeSize(): Int {
return 1 + typeArguments.sumBy { ((it as? ConeKotlinType)?.subtreeSize() ?: 0) + 1 }
return 1 + typeArguments.sumOf { ((it as? ConeKotlinType)?.subtreeSize() ?: 0) + 1 }
}
private fun coneFlexibleOrSimpleType(
@@ -44,7 +44,7 @@ abstract class BaseMultimap<K, V, C : Collection<V>, MC : MutableCollection<V>>
override val values: Collection<V>
get() = object : AbstractCollection<V>() {
override val size: Int
get() = map.values.sumBy { it.size }
get() = map.values.sumOf { it.size }
override fun iterator(): Iterator<V> {
return ChainedIterator(map.values.map { it.iterator() })
@@ -809,7 +809,7 @@ class TypeResolver(
val restParameters = parameters.subList(result.size, parameters.size)
val typeArgumentsCanBeSpecifiedCount =
classifierDescriptor.classifierDescriptorsFromInnerToOuter().sumBy { it.declaredTypeParameters.size }
classifierDescriptor.classifierDescriptorsFromInnerToOuter().sumOf { it.declaredTypeParameters.size }
if (restArguments == null && typeArgumentsCanBeSpecifiedCount > result.size) {
c.trace.report(
@@ -87,7 +87,7 @@ class KotlinResolutionCandidate(
private var currentApplicability = CandidateApplicability.RESOLVED
private var subResolvedAtoms: MutableList<ResolvedAtom> = arrayListOf()
private val stepCount = resolutionSequence.sumBy { it.run { workCount() } }
private val stepCount = resolutionSequence.sumOf { it.run { workCount() } }
private var step = 0
fun getSystem(): NewConstraintSystem {
@@ -72,7 +72,7 @@ class FirResolveBench(val withProgress: Boolean, val listener: BenchListener? =
user = sumByLong { it.user }
cpu = sumByLong { it.cpu }
gcTime = sumByLong { it.gcTime }
gcCollections = sumBy { it.gcCollections }
gcCollections = sumOf { it.gcCollections }
files = map { it.files }.average().toInt()
}
}
@@ -161,7 +161,7 @@ class FirResolveBench(val withProgress: Boolean, val listener: BenchListener? =
this.files += 1
this.user += diff.userTime
this.cpu += diff.cpuTime
this.gcCollections += diff.gcInfo.values.sumBy { it.collections.toInt() }
this.gcCollections += diff.gcInfo.values.sumOf { it.collections.toInt() }
this.gcTime += diff.gcInfo.values.sumByLong { it.gcTime }
}
}
@@ -56,7 +56,7 @@ fun bytesToStrings(bytes: ByteArray): Array<String> {
}
fun stringsToBytes(strings: Array<String>): ByteArray {
val resultLength = strings.sumBy { it.length }
val resultLength = strings.sumOf { it.length }
val result = ByteArray(resultLength)
var i = 0
@@ -123,7 +123,7 @@ internal fun <T : Any> createAnnotationInstance(
}
val hashCode by lazy {
values.entries.sumBy { entry ->
values.entries.sumOf { entry ->
val (key, value) = entry
val valueHash = when (value) {
is BooleanArray -> Arrays.hashCode(value)
@@ -280,7 +280,7 @@ class SerializableCodegenImpl(
val superProps = bindingContext.serializablePropertiesFor(superClass).serializableProperties
val creator = buildInternalConstructorDesc(propStartVar, maskVar, classCodegen, superProps)
invokespecial(superType, "<init>", creator, false)
return superProps.size to propStartVar + superProps.sumBy { it.asmType.size }
return superProps.size to propStartVar + superProps.sumOf { it.asmType.size }
}
}