From 4ad3e429aa9a1daa23c12dc76101f11566736666 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 31 May 2019 14:25:41 +0300 Subject: [PATCH] FirClassDeclaredMemberScope: use just Name instead of ClassId/CallableId This should decrease amount of created garbage a little bit --- .../impl/FirClassDeclaredMemberScope.kt | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt index c95be577e21..f73e0bf526d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt @@ -13,32 +13,27 @@ import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT import org.jetbrains.kotlin.fir.scopes.ProcessorAction.STOP import org.jetbrains.kotlin.fir.symbols.* -import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name -class FirClassDeclaredMemberScope( - klass: FirRegularClass -) : FirScope { - private val classId = klass.symbol.classId +class FirClassDeclaredMemberScope(klass: FirRegularClass) : FirScope { private val callablesIndex by lazy { klass.declarations.filterIsInstance() - .map { it.symbol }.groupBy { it.callableId } + .map { it.symbol }.groupBy { it.callableId.callableName } } private val classIndex by lazy { klass.declarations.filterIsInstance() - .map { it.symbol }.associateBy { it.classId } + .map { it.symbol }.associateBy { it.fir.name } } - override fun processFunctionsByName(name: Name, processor: (ConeFunctionSymbol) -> ProcessorAction): ProcessorAction { - val matchedClass = classIndex[ClassId(classId.packageFqName, classId.relativeClassName.child(name), false)] + val matchedClass = classIndex[name] if (matchedClass != null) { if (FirClassDeclaredMemberScope(matchedClass.fir).processFunctionsByName(name, processor) == STOP) { return STOP } } - val symbols = callablesIndex[CallableId(classId.packageFqName, classId.relativeClassName, name)] ?: emptyList() + val symbols = callablesIndex[name] ?: emptyList() for (symbol in symbols) { if (symbol is ConeFunctionSymbol && !processor(symbol)) { return STOP @@ -48,7 +43,7 @@ class FirClassDeclaredMemberScope( } override fun processPropertiesByName(name: Name, processor: (ConeVariableSymbol) -> ProcessorAction): ProcessorAction { - val symbols = callablesIndex[CallableId(classId.packageFqName, classId.relativeClassName, name)] ?: emptyList() + val symbols = callablesIndex[name] ?: emptyList() for (symbol in symbols) { if (symbol is ConePropertySymbol && !processor(symbol)) { return STOP @@ -58,7 +53,7 @@ class FirClassDeclaredMemberScope( } override fun processClassifiersByName(name: Name, position: FirPosition, processor: (ConeClassifierSymbol) -> Boolean): Boolean { - val matchedClass = classIndex[classId.createNestedClassId(name)] + val matchedClass = classIndex[name] if (matchedClass != null && !processor(matchedClass)) { return false }