[JS IR DCE] Move withNested fun to get better diff in the next commit

This commit is contained in:
Zalim Bashorov
2020-01-10 17:03:36 +03:00
parent 95d248189f
commit e6657b016f
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -94,7 +94,19 @@ private fun removeUselessDeclarations(module: IrModuleFragment, usefulDeclaratio
} }
} }
private fun Iterable<IrDeclaration>.withNested(): Iterable<IrDeclaration> { fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendContext): Set<IrDeclaration> {
val queue = ArrayDeque<IrDeclaration>()
val result = hashSetOf<IrDeclaration>()
val constructedClasses = hashSetOf<IrClass>()
fun IrDeclaration.enqueue() {
if ((this !is IrProperty || this.isExternal) && this !in result) {
result.add(this)
queue.addLast(this)
}
}
fun Iterable<IrDeclaration>.withNested(): Iterable<IrDeclaration> {
val result = mutableListOf<IrDeclaration>() val result = mutableListOf<IrDeclaration>()
this.forEach { this.forEach {
@@ -117,18 +129,6 @@ private fun Iterable<IrDeclaration>.withNested(): Iterable<IrDeclaration> {
return result return result
} }
fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendContext): Set<IrDeclaration> {
val queue = ArrayDeque<IrDeclaration>()
val result = hashSetOf<IrDeclaration>()
val constructedClasses = hashSetOf<IrClass>()
fun IrDeclaration.enqueue() {
if ((this !is IrProperty || this.isExternal) && this !in result) {
result.add(this)
queue.addLast(this)
}
}
// Add roots, including nested declarations // Add roots, including nested declarations
stageController.withInitialIr { stageController.withInitialIr {
roots.withNested().forEach { it.enqueue() } roots.withNested().forEach { it.enqueue() }