avoid unnecessary collection copying
This commit is contained in:
committed by
teamcityserver
parent
42837415f0
commit
0495ba2495
+2
-2
@@ -225,7 +225,7 @@ protected constructor(
|
||||
kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean,
|
||||
location: LookupLocation
|
||||
): List<DeclarationDescriptor> {
|
||||
): MutableSet<DeclarationDescriptor> {
|
||||
val declarations = declarationProvider.getDeclarations(kindFilter, nameFilter)
|
||||
val result = LinkedHashSet<DeclarationDescriptor>(declarations.size)
|
||||
for (declaration in declarations) {
|
||||
@@ -272,7 +272,7 @@ protected constructor(
|
||||
else -> throw IllegalArgumentException("Unsupported declaration kind: " + declaration)
|
||||
}
|
||||
}
|
||||
return result.toList()
|
||||
return result
|
||||
}
|
||||
|
||||
// Do not change this, override in concrete subclasses:
|
||||
|
||||
+10
-18
@@ -65,14 +65,12 @@ open class LazyClassMemberScope(
|
||||
}
|
||||
|
||||
private fun doDescriptors(nameFilter: (Name) -> Boolean): List<DeclarationDescriptor> {
|
||||
val result = LinkedHashSet(
|
||||
computeDescriptorsFromDeclaredElements(
|
||||
DescriptorKindFilter.ALL,
|
||||
nameFilter,
|
||||
NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS
|
||||
)
|
||||
val result = computeDescriptorsFromDeclaredElements(
|
||||
DescriptorKindFilter.ALL,
|
||||
nameFilter,
|
||||
NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS
|
||||
)
|
||||
result.addAll(computeExtraDescriptors(NoLookupLocation.FOR_ALREADY_TRACKED))
|
||||
computeExtraDescriptors(result, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
return result.toList()
|
||||
}
|
||||
|
||||
@@ -81,12 +79,10 @@ open class LazyClassMemberScope(
|
||||
}
|
||||
|
||||
private fun doClassifierDescriptors(nameFilter: (Name) -> Boolean): List<DeclarationDescriptor> {
|
||||
val result = LinkedHashSet(
|
||||
computeDescriptorsFromDeclaredElements(
|
||||
DescriptorKindFilter.CLASSIFIERS,
|
||||
nameFilter,
|
||||
NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS
|
||||
)
|
||||
val result = computeDescriptorsFromDeclaredElements(
|
||||
DescriptorKindFilter.CLASSIFIERS,
|
||||
nameFilter,
|
||||
NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS
|
||||
)
|
||||
addSyntheticCompanionObject(result, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
addSyntheticNestedClasses(result, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
@@ -115,8 +111,7 @@ open class LazyClassMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun computeExtraDescriptors(location: LookupLocation): Collection<DeclarationDescriptor> {
|
||||
val result = ArrayList<DeclarationDescriptor>()
|
||||
protected open fun computeExtraDescriptors(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
|
||||
for (supertype in supertypes) {
|
||||
for (descriptor in supertype.memberScope.getContributedDescriptors()) {
|
||||
if (descriptor is FunctionDescriptor) {
|
||||
@@ -133,9 +128,6 @@ open class LazyClassMemberScope(
|
||||
addSyntheticVariables(result, location)
|
||||
addSyntheticCompanionObject(result, location)
|
||||
addSyntheticNestedClasses(result, location)
|
||||
|
||||
result.trimToSize()
|
||||
return result
|
||||
}
|
||||
|
||||
val supertypes by storageManager.createLazyValue {
|
||||
|
||||
Reference in New Issue
Block a user