Use fqName
Add BooleanArray Use set
This commit is contained in:
committed by
KonstantinAnisimov
parent
666f052b10
commit
1e134f7062
+21
-3
@@ -310,10 +310,28 @@ internal fun DeclarationDescriptor.getMemberScope(): MemberScope {
|
||||
}
|
||||
|
||||
// It is possible to declare "external inline fun",
|
||||
// but it doesn't have much sence for native,
|
||||
// but it doesn't have much sense for native,
|
||||
// since externals don't have IR bodies.
|
||||
internal val FunctionDescriptor.needsInlining: Boolean
|
||||
get() = (this.isInline && !this.isExternal)
|
||||
|
||||
// Enforce inlining of some constructors (ByteArray, IntArray, ...)
|
||||
val mustInlineFunctions = setOf(
|
||||
"kotlin.DoubleArray.<init>",
|
||||
"kotlin.FloatArray.<init>",
|
||||
"kotlin.ByteArray.<init>",
|
||||
"kotlin.ShortArray.<init>",
|
||||
"kotlin.IntArray.<init>",
|
||||
"kotlin.LongArray.<init>",
|
||||
"kotlin.CharArray.<init>",
|
||||
"kotlin.BooleanArray.<init>"
|
||||
)
|
||||
|
||||
internal val FunctionDescriptor.needsInlining: Boolean
|
||||
get(): Boolean {
|
||||
val needs = this.isInline && !this.isExternal
|
||||
if (valueParameters.size != 2) return needs // Constructor must have two parameters.
|
||||
if (mustInlineFunctions.contains(fqNameSafe.toString())) return true
|
||||
return needs
|
||||
}
|
||||
|
||||
internal val FunctionDescriptor.needsSerializedIr: Boolean
|
||||
get() = (this.needsInlining && this.isExported())
|
||||
|
||||
+1
-23
@@ -56,7 +56,7 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoidW
|
||||
|
||||
val irCall = super.visitCall(expression) as IrCall
|
||||
val functionDescriptor = irCall.descriptor as FunctionDescriptor
|
||||
if (!needsInlining(functionDescriptor)) return irCall // This call does not need inlining.
|
||||
if (!functionDescriptor.needsInlining) return irCall // This call does not need inlining.
|
||||
|
||||
val functionDeclaration = getFunctionDeclaration(irCall) // Get declaration of the function to be inlined.
|
||||
if (functionDeclaration == null) { // We failed to get the declaration.
|
||||
@@ -83,28 +83,6 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoidW
|
||||
return functionDeclaration as IrFunction?
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
// Enforce inlining of some constructors (ByteArray, IntArray, ...)
|
||||
|
||||
private fun needsInlining(functionDescriptor: FunctionDescriptor): Boolean {
|
||||
|
||||
val needsInlining = functionDescriptor.needsInlining
|
||||
val functionName = functionDescriptor.name.toString()
|
||||
if (functionName != "<init>") return needsInlining // This is not constructor.
|
||||
if (functionDescriptor.valueParameters.size != 2) return needsInlining // Constructor must have two parameters.
|
||||
|
||||
val returnType = functionDescriptor.returnType.toString()
|
||||
if (returnType == "DoubleArray") return true
|
||||
if (returnType == "FloatArray" ) return true
|
||||
if (returnType == "ByteArray" ) return true
|
||||
if (returnType == "ShortArray" ) return true
|
||||
if (returnType == "IntArray" ) return true
|
||||
if (returnType == "LongArray" ) return true
|
||||
if (returnType == "CharArray" ) return true
|
||||
|
||||
return needsInlining
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
override fun visitElement(element: IrElement) = element.accept(this, null)
|
||||
|
||||
Reference in New Issue
Block a user