Introduce getFunctionNames and getVariableNames into MemberScope
Also provide some basic implementation The main purpose of these methods is optimization. Most of the member scopes store mapping from names to descriptors MemoizedFunction<Name, Collection<Descriptor>> While there are 10 functions in class in average, there are a lot of queries with names of non-existent functions, that leads to many effectively redundant Map nodes in MemoizedFunction and also cause additional computation that is worth to compute at once
This commit is contained in:
+7
@@ -70,6 +70,13 @@ class JvmPackageScope(
|
||||
): Collection<DeclarationDescriptor> =
|
||||
getFromAllScopes(javaScope, kotlinScopes) { it.getContributedDescriptors(kindFilter, nameFilter) }
|
||||
|
||||
override fun getFunctionNames() = kotlinScopes.flatMapTo(mutableSetOf()) { it.getFunctionNames() }.apply {
|
||||
addAll(javaScope.getFunctionNames())
|
||||
}
|
||||
override fun getVariableNames() = kotlinScopes.flatMapTo(mutableSetOf()) { it.getVariableNames() }.apply {
|
||||
addAll(javaScope.getVariableNames())
|
||||
}
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(javaClass.simpleName, " {")
|
||||
p.pushIndent()
|
||||
|
||||
+2
-2
@@ -627,8 +627,8 @@ class LazyJavaClassMemberScope(
|
||||
if (jNestedClass == null) {
|
||||
val field = enumEntryIndex()[name]
|
||||
if (field != null) {
|
||||
val enumMemberNames: NotNullLazyValue<Collection<Name>> = c.storageManager.createLazyValue {
|
||||
memberIndex().getAllFieldNames() + memberIndex().getMethodNames({ true })
|
||||
val enumMemberNames: NotNullLazyValue<Set<Name>> = c.storageManager.createLazyValue {
|
||||
(memberIndex().getAllFieldNames() + memberIndex().getMethodNames({ true })).toSet()
|
||||
}
|
||||
EnumEntrySyntheticClassDescriptor.create(
|
||||
c.storageManager, ownerDescriptor, name, enumMemberNames, c.resolveAnnotations(field),
|
||||
|
||||
Reference in New Issue
Block a user