[JS IR DCE] Move withNested fun to get better diff in the next commit
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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>()
|
||||
|
||||
this.forEach {
|
||||
@@ -117,18 +129,6 @@ private fun Iterable<IrDeclaration>.withNested(): Iterable<IrDeclaration> {
|
||||
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
|
||||
stageController.withInitialIr {
|
||||
roots.withNested().forEach { it.enqueue() }
|
||||
|
||||
Reference in New Issue
Block a user