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:
Denis Zharkov
2018-07-18 13:05:11 +03:00
parent 2fd9b3ee35
commit 8050869e45
5 changed files with 9 additions and 5 deletions
@@ -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