Minor: formatted code

This commit is contained in:
Dmitriy Dolovov
2019-12-27 15:05:12 +07:00
parent e0d90ccf4b
commit 7ffb64ec57
8 changed files with 20 additions and 55 deletions
@@ -30,23 +30,13 @@ class DeclarationsBuilderCache(dimension: Int) {
check(dimension > 0)
}
private val modules =
CommonizedGroup<List<ModuleDescriptorImpl>>(dimension)
private val packageFragments =
CommonizedGroupMap<Pair<Name, FqName>, CommonizedPackageFragmentDescriptor>(
dimension
)
private val classes =
CommonizedGroupMap<FqName, CommonizedClassDescriptor>(dimension)
private val typeAliases =
CommonizedGroupMap<FqName, CommonizedTypeAliasDescriptor>(
dimension
)
private val modules = CommonizedGroup<List<ModuleDescriptorImpl>>(dimension)
private val packageFragments = CommonizedGroupMap<Pair<Name, FqName>, CommonizedPackageFragmentDescriptor>(dimension)
private val classes = CommonizedGroupMap<FqName, CommonizedClassDescriptor>(dimension)
private val typeAliases = CommonizedGroupMap<FqName, CommonizedTypeAliasDescriptor>(dimension)
private val forwardDeclarationsModules =
CommonizedGroup<ModuleDescriptorImpl>(dimension)
private val allModulesWithDependencies =
CommonizedGroup<List<ModuleDescriptor>>(dimension)
private val forwardDeclarationsModules = CommonizedGroup<ModuleDescriptorImpl>(dimension)
private val allModulesWithDependencies = CommonizedGroup<List<ModuleDescriptor>>(dimension)
fun getCachedPackageFragments(moduleName: Name, packageFqName: FqName): List<CommonizedPackageFragmentDescriptor?> =
packageFragments.getOrFail(moduleName to packageFqName)
@@ -89,8 +89,7 @@ internal class CommonizationVisitor(
}
// find out common (and commonized) supertypes
val supertypesMap =
CommonizedGroupMap<String, CirType>(node.target.size)
val supertypesMap = CommonizedGroupMap<String, CirType>(node.target.size)
node.target.forEachIndexed { index, clazz ->
for (supertype in clazz!!.supertypes) {
supertypesMap[supertype.fqNameWithTypeParameters][index] = supertype
@@ -154,7 +154,7 @@ class NativeDistributionCommonizer(
"""
library has incompatible metadata version ${metadataVersion ?: "\"unknown\""}: $location,
please make sure that all libraries passed to commonizer compatible metadata version ${KlibMetadataVersion.INSTANCE}
""".trimIndent()
""".trimIndent()
)
return library
@@ -23,20 +23,10 @@ internal fun mergeClasses(
): CirClassNode {
val node = buildClassNode(storageManager, cacheRW, containingDeclarationCommon, classes)
val constructorsMap =
CommonizedGroupMap<ConstructorApproximationKey, ClassConstructorDescriptor>(
classes.size
)
val propertiesMap =
CommonizedGroupMap<PropertyApproximationKey, PropertyDescriptor>(
classes.size
)
val functionsMap =
CommonizedGroupMap<FunctionApproximationKey, SimpleFunctionDescriptor>(
classes.size
)
val classesMap =
CommonizedGroupMap<Name, ClassDescriptor>(classes.size)
val constructorsMap = CommonizedGroupMap<ConstructorApproximationKey, ClassConstructorDescriptor>(classes.size)
val propertiesMap = CommonizedGroupMap<PropertyApproximationKey, PropertyDescriptor>(classes.size)
val functionsMap = CommonizedGroupMap<FunctionApproximationKey, SimpleFunctionDescriptor>(classes.size)
val classesMap = CommonizedGroupMap<Name, ClassDescriptor>(classes.size)
classes.forEachIndexed { index, clazz ->
clazz?.constructors?.forEach { constructorsMap[ConstructorApproximationKey(it)][index] = it }
@@ -24,8 +24,7 @@ internal fun mergeModules(
): CirModuleNode {
val node = buildModuleNode(storageManager, modules)
val packageMemberScopesMap =
CommonizedGroupMap<FqName, MemberScope>(modules.size)
val packageMemberScopesMap = CommonizedGroupMap<FqName, MemberScope>(modules.size)
modules.forEachIndexed { index, module ->
module?.collectNonEmptyPackageMemberScopes { packageFqName, memberScope ->
@@ -27,19 +27,10 @@ internal fun mergePackages(
): CirPackageNode {
val node = buildPackageNode(storageManager, moduleName, packageFqName, packageMemberScopes)
val propertiesMap =
CommonizedGroupMap<PropertyApproximationKey, PropertyDescriptor>(
packageMemberScopes.size
)
val functionsMap =
CommonizedGroupMap<FunctionApproximationKey, SimpleFunctionDescriptor>(
packageMemberScopes.size
)
val classesMap =
CommonizedGroupMap<Name, ClassDescriptor>(packageMemberScopes.size)
val typeAliasesMap = CommonizedGroupMap<Name, TypeAliasDescriptor>(
packageMemberScopes.size
)
val propertiesMap = CommonizedGroupMap<PropertyApproximationKey, PropertyDescriptor>(packageMemberScopes.size)
val functionsMap = CommonizedGroupMap<FunctionApproximationKey, SimpleFunctionDescriptor>(packageMemberScopes.size)
val classesMap = CommonizedGroupMap<Name, ClassDescriptor>(packageMemberScopes.size)
val typeAliasesMap = CommonizedGroupMap<Name, TypeAliasDescriptor>(packageMemberScopes.size)
packageMemberScopes.forEachIndexed { index, memberScope ->
memberScope?.collectMembers(
@@ -19,8 +19,7 @@ internal fun mergeRoots(
): CirRootNode {
val node = buildRootNode(storageManager, modulesByTargets.map { it.first })
val modulesMap =
CommonizedGroupMap<Name, ModuleDescriptor>(modulesByTargets.size)
val modulesMap = CommonizedGroupMap<Name, ModuleDescriptor>(modulesByTargets.size)
modulesByTargets.forEachIndexed { index, (_, modules) ->
for (module in modules) {
@@ -41,11 +41,8 @@ internal class CommonizedGroup<T : Any>(
internal class CommonizedGroupMap<K, V : Any>(val size: Int) : Iterable<Map.Entry<K, CommonizedGroup<V>>> {
private val wrapped: MutableMap<K, CommonizedGroup<V>> = HashMap()
operator fun get(key: K): CommonizedGroup<V> = wrapped.getOrPut(key) {
CommonizedGroup(
size
)
}
operator fun get(key: K): CommonizedGroup<V> = wrapped.getOrPut(key) { CommonizedGroup(size) }
fun getOrNull(key: K): CommonizedGroup<V>? = wrapped[key]
override fun iterator(): Iterator<Map.Entry<K, CommonizedGroup<V>>> = wrapped.iterator()