mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[plugins] BAZEL-1041: iterate maps more efficiently in IdeaPluginDescriptorImpl.doRegisterExtensions
GitOrigin-RevId: 5ed54dfe9d5520e2c0f46b75f9e1700a03a404e7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d9142b0d7a
commit
6c46345ea6
@@ -517,14 +517,26 @@ class IdeaPluginDescriptorImpl(
|
||||
nameToPoint: Map<String, ExtensionPointImpl<*>>,
|
||||
listenerCallbacks: MutableList<in Runnable>?): Int {
|
||||
var registeredCount = 0
|
||||
for (entry in map) {
|
||||
val point = nameToPoint.get(entry.key) ?: continue
|
||||
point.registerExtensions(descriptors = entry.value, pluginDescriptor = this, listenerCallbacks = listenerCallbacks)
|
||||
for ((descriptors, point) in intersectMaps(map, nameToPoint)) {
|
||||
point.registerExtensions(descriptors = descriptors, pluginDescriptor = this, listenerCallbacks = listenerCallbacks)
|
||||
registeredCount++
|
||||
}
|
||||
return registeredCount
|
||||
}
|
||||
|
||||
private fun <K, V1, V2> intersectMaps(first: Map<K, V1>, second: Map<K, V2>): List<Pair<V1, V2>> {
|
||||
// Make sure we iterate the smaller map
|
||||
if (first.size < second.size) {
|
||||
return first.mapNotNull { (key, firstValue) ->
|
||||
second[key]?.let { secondValue -> firstValue to secondValue }
|
||||
}
|
||||
} else {
|
||||
return second.mapNotNull { (key, secondValue) ->
|
||||
first[key]?.let { firstValue -> firstValue to secondValue }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("HardCodedStringLiteral")
|
||||
override fun getDescription(): String? {
|
||||
var result = description
|
||||
|
||||
Reference in New Issue
Block a user