Make withSubtypesOf more efficent
This commit is contained in:
@@ -738,19 +738,21 @@ private fun CompilationResult.doProcessChangesUsingLookups(
|
|||||||
) {
|
) {
|
||||||
val dirtyLookupSymbols = HashSet<LookupSymbol>()
|
val dirtyLookupSymbols = HashSet<LookupSymbol>()
|
||||||
val lookupStorage = dataManager.getStorage(KotlinDataContainerTarget, LookupStorageProvider)
|
val lookupStorage = dataManager.getStorage(KotlinDataContainerTarget, LookupStorageProvider)
|
||||||
|
val allCaches = caches.toHashSet()
|
||||||
|
allCaches.addAll(caches.flatMap { it.dependentCaches })
|
||||||
|
|
||||||
KotlinBuilder.LOG.debug("Start processing changes")
|
KotlinBuilder.LOG.debug("Start processing changes")
|
||||||
|
|
||||||
for (change in changes) {
|
for (change in changes) {
|
||||||
if (change is ChangeInfo.SignatureChanged) {
|
if (change is ChangeInfo.SignatureChanged) {
|
||||||
for (classFqName in withSubtypes(change.fqName, caches)) {
|
for (classFqName in withSubtypes(change.fqName, allCaches)) {
|
||||||
val scope = classFqName.parent().asString()
|
val scope = classFqName.parent().asString()
|
||||||
val name = classFqName.shortName().identifier
|
val name = classFqName.shortName().identifier
|
||||||
dirtyLookupSymbols.add(LookupSymbol(name, scope))
|
dirtyLookupSymbols.add(LookupSymbol(name, scope))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (change is ChangeInfo.MembersChanged) {
|
else if (change is ChangeInfo.MembersChanged) {
|
||||||
val scopes = withSubtypes(change.fqName, caches).map { it.asString() }
|
val scopes = withSubtypes(change.fqName, allCaches).map { it.asString() }
|
||||||
|
|
||||||
change.names.forAllPairs(scopes) { name, scope ->
|
change.names.forAllPairs(scopes) { name, scope ->
|
||||||
dirtyLookupSymbols.add(LookupSymbol(name, scope))
|
dirtyLookupSymbols.add(LookupSymbol(name, scope))
|
||||||
@@ -781,9 +783,6 @@ private fun CompilationResult.doProcessChangesUsingLookups(
|
|||||||
* class C : B()
|
* class C : B()
|
||||||
* withSubtypes(A) will return [A, B, C]
|
* withSubtypes(A) will return [A, B, C]
|
||||||
*/
|
*/
|
||||||
/* TODO: in case of chunk containing more than one target,
|
|
||||||
depending targets would be asked about same subtype more than once.
|
|
||||||
Can be solved by putting all caches in set */
|
|
||||||
private fun withSubtypes(
|
private fun withSubtypes(
|
||||||
typeFqName: FqName,
|
typeFqName: FqName,
|
||||||
caches: Collection<IncrementalCacheImpl>
|
caches: Collection<IncrementalCacheImpl>
|
||||||
|
|||||||
@@ -107,6 +107,9 @@ class IncrementalCacheImpl(
|
|||||||
private val dependentsWithThis: Sequence<IncrementalCacheImpl>
|
private val dependentsWithThis: Sequence<IncrementalCacheImpl>
|
||||||
get() = sequenceOf(this).plus(dependents.asSequence())
|
get() = sequenceOf(this).plus(dependents.asSequence())
|
||||||
|
|
||||||
|
internal val dependentCaches: Iterable<IncrementalCacheImpl>
|
||||||
|
get() = dependents
|
||||||
|
|
||||||
override fun registerInline(fromPath: String, jvmSignature: String, toPath: String) {
|
override fun registerInline(fromPath: String, jvmSignature: String, toPath: String) {
|
||||||
if (!IncrementalCompilation.isExperimental()) {
|
if (!IncrementalCompilation.isExperimental()) {
|
||||||
inlinedTo.add(fromPath, jvmSignature, toPath)
|
inlinedTo.add(fromPath, jvmSignature, toPath)
|
||||||
@@ -144,7 +147,7 @@ class IncrementalCacheImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getSubtypesOf(className: FqName): Sequence<FqName> =
|
fun getSubtypesOf(className: FqName): Sequence<FqName> =
|
||||||
dependentsWithThis.flatMap { it.subtypesMap[className].asSequence() }
|
subtypesMap[className].asSequence()
|
||||||
|
|
||||||
fun cleanDirtyInlineFunctions() {
|
fun cleanDirtyInlineFunctions() {
|
||||||
dirtyInlineFunctionsMap.clean()
|
dirtyInlineFunctionsMap.clean()
|
||||||
|
|||||||
Reference in New Issue
Block a user