Use THashSet for sets that are assumed to be big
Otherwise, a lot of memory is wasted on nodes instances (cherry picked from commit 4922f87)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.lazy
|
||||
|
||||
import gnu.trove.THashSet
|
||||
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMap
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -248,7 +249,7 @@ class FileScopeFactory(
|
||||
parentScope: ImportingScope
|
||||
): ImportingScope {
|
||||
val scope = packageView.memberScope
|
||||
val names by lazy(LazyThreadSafetyMode.PUBLICATION) { scope.computeAllNames() }
|
||||
val names by lazy(LazyThreadSafetyMode.PUBLICATION) { scope.computeAllNames()?.let(::THashSet) }
|
||||
val packageName = packageView.fqName
|
||||
val excludedNames = aliasImportNames.mapNotNull { if (it.parent() == packageName) it.shortName() else null }
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.lazy
|
||||
import com.google.common.collect.HashMultimap
|
||||
import com.google.common.collect.ImmutableListMultimap
|
||||
import com.google.common.collect.ListMultimap
|
||||
import gnu.trove.THashSet
|
||||
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMap
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -135,7 +136,7 @@ open class LazyImportResolver<I : KtImportInfo>(
|
||||
}
|
||||
|
||||
val allNames: Set<Name>? by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
indexedImports.imports.flatMapToNullable(hashSetOf()) { getImportScope(it).computeImportedNames() }
|
||||
indexedImports.imports.flatMapToNullable(THashSet()) { getImportScope(it).computeImportedNames() }
|
||||
}
|
||||
|
||||
fun definitelyDoesNotContainName(name: Name) = allNames?.let { name !in it } == true
|
||||
|
||||
Reference in New Issue
Block a user