IR: optimize IrAnnotationContainer.copyAnnotations
Annotation arguments cannot contain declarations, so we can use empty SymbolRemapper instead of DeepCopySymbolRemapper because the latter introduces some overhead. #KT-66281
This commit is contained in:
committed by
Space Team
parent
d5c2aa4c0c
commit
ee506c1369
@@ -1031,13 +1031,10 @@ private fun IrTypeParameter.copySuperTypesFrom(source: IrTypeParameter, srcToDst
|
||||
}
|
||||
}
|
||||
|
||||
fun IrAnnotationContainer.copyAnnotations(): List<IrConstructorCall> {
|
||||
return annotations.memoryOptimizedMap { it.deepCopyWithSymbols(this as? IrDeclarationParent) }
|
||||
}
|
||||
|
||||
fun IrAnnotationContainer.copyAnnotationsWhen(filter: IrConstructorCall.() -> Boolean): List<IrConstructorCall> {
|
||||
return annotations.mapNotNull { if (it.filter()) it.deepCopyWithSymbols(this as? IrDeclarationParent) else null }
|
||||
}
|
||||
fun IrAnnotationContainer.copyAnnotations(): List<IrConstructorCall> =
|
||||
annotations.memoryOptimizedMap {
|
||||
it.transform(DeepCopyIrTreeWithSymbols(SymbolRemapper.EMPTY), null) as IrConstructorCall
|
||||
}
|
||||
|
||||
fun IrMutableAnnotationContainer.copyAnnotationsFrom(source: IrAnnotationContainer) {
|
||||
annotations = annotations memoryOptimizedPlus source.copyAnnotations()
|
||||
|
||||
@@ -110,4 +110,7 @@ interface SymbolRemapper {
|
||||
override fun getReferencedTypeAlias(symbol: IrTypeAliasSymbol): IrTypeAliasSymbol = symbol
|
||||
}
|
||||
|
||||
}
|
||||
companion object {
|
||||
val EMPTY: SymbolRemapper = Empty()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user