[FIR] FirLocalVariableAssignmentAnalyzer: do not try to propagate empty information
`recordAssignments` merges properties into all parents which is redundant work in the case of empty `VariableAssignments`. This redundant work leads to critically poor performance in cases with many local declarations. ^KT-66416 Fixed
This commit is contained in:
committed by
Space Team
parent
405852980d
commit
de74ca5902
+6
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -10,12 +10,12 @@ import org.jetbrains.kotlin.fir.FirElement
|
|||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.explicitReceiver
|
||||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirReference
|
import org.jetbrains.kotlin.fir.references.FirReference
|
||||||
import org.jetbrains.kotlin.fir.references.toResolvedPropertySymbol
|
import org.jetbrains.kotlin.fir.references.toResolvedPropertySymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||||
import org.jetbrains.kotlin.fir.expressions.explicitReceiver
|
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
import org.jetbrains.kotlin.fir.types.typeContext
|
import org.jetbrains.kotlin.fir.types.typeContext
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||||
@@ -327,6 +327,8 @@ internal class FirLocalVariableAssignmentAnalyzer {
|
|||||||
fun retain(properties: Set<FirProperty>) {
|
fun retain(properties: Set<FirProperty>) {
|
||||||
assignments.keys.retainAll(properties)
|
assignments.keys.retainAll(properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isEmpty(): Boolean = assignments.isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MiniFlow(val parents: Set<MiniFlow>) {
|
private class MiniFlow(val parents: Set<MiniFlow>) {
|
||||||
@@ -480,6 +482,8 @@ internal class FirLocalVariableAssignmentAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun MiniFlow.recordAssignments(properties: VariableAssignments) {
|
private fun MiniFlow.recordAssignments(properties: VariableAssignments) {
|
||||||
|
if (properties.isEmpty()) return
|
||||||
|
|
||||||
assignedLater.merge(properties)
|
assignedLater.merge(properties)
|
||||||
parents.forEach { it.recordAssignments(properties) }
|
parents.forEach { it.recordAssignments(properties) }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user