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:
+2
-1
@@ -24,6 +24,7 @@ import com.intellij.psi.*
|
||||
import com.intellij.psi.impl.file.PsiPackageImpl
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import gnu.trove.THashMap
|
||||
import gnu.trove.THashSet
|
||||
import org.jetbrains.kotlin.cli.jvm.index.JavaRoot
|
||||
import org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndex
|
||||
import org.jetbrains.kotlin.cli.jvm.index.SingleJavaFileRootsIndex
|
||||
@@ -216,7 +217,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
|
||||
}
|
||||
|
||||
override fun knownClassNamesInPackage(packageFqName: FqName): Set<String> {
|
||||
val result = hashSetOf<String>()
|
||||
val result = THashSet<String>()
|
||||
index.traverseDirectoriesInPackage(packageFqName, continueSearch = { dir, _ ->
|
||||
for (child in dir.children) {
|
||||
if (child.extension == "class" || child.extension == "java") {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.daemon
|
||||
|
||||
import com.intellij.util.containers.StringInterner
|
||||
import gnu.trove.THashSet
|
||||
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
|
||||
import org.jetbrains.kotlin.daemon.common.DummyProfiler
|
||||
import org.jetbrains.kotlin.daemon.common.Profiler
|
||||
@@ -29,7 +30,7 @@ import org.jetbrains.kotlin.incremental.components.ScopeKind
|
||||
class RemoteLookupTrackerClient(val facade: CompilerCallbackServicesFacade, eventManager: EventManager, val profiler: Profiler = DummyProfiler()) : LookupTracker {
|
||||
private val isDoNothing = profiler.withMeasure(this) { facade.lookupTracker_isDoNothing() }
|
||||
|
||||
private val lookups = hashSetOf<LookupInfo>()
|
||||
private val lookups = THashSet<LookupInfo>()
|
||||
private val interner = StringInterner()
|
||||
|
||||
override val requiresPosition: Boolean = profiler.withMeasure(this) { facade.lookupTracker_requiresPosition() }
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ class LazyJavaClassMemberScope(
|
||||
override fun computeMemberIndex() = ClassDeclaredMemberIndex(jClass, { !it.isStatic })
|
||||
|
||||
override fun computeFunctionNames(kindFilter: DescriptorKindFilter, nameFilter: ((Name) -> Boolean)?) =
|
||||
ownerDescriptor.typeConstructor.supertypes.flatMapTo(HashSet()) {
|
||||
ownerDescriptor.typeConstructor.supertypes.flatMapTo(hashSetOf()) {
|
||||
it.memberScope.getFunctionNames()
|
||||
}.apply {
|
||||
addAll(declaredMemberIndex().getMethodNames())
|
||||
|
||||
Reference in New Issue
Block a user