diff --git a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt index bb6556b1de..8cc4c4c01e 100644 --- a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt @@ -31,7 +31,7 @@ private fun remap(i: Int, argType: Type, localIndex: Int): Int { } private fun remapAll(indexes: List, argType: Type, localIndex: Int): MutableList { - return indexes.map { remap(it, argType, localIndex) }.toMutableList() + return indexes.mapTo(mutableListOf()) { remap(it, argType, localIndex) } } fun MethodNode.removeArgument(argIndex: Int) { diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt index 3805db3359..c122242629 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt @@ -19,13 +19,13 @@ class AsmClassMetadata( get() = clazz.superName?.let { classPath[it] ?: error("Failed to find $it on provided classpath.") } override val superInterfaces - get() = clazz.interfaces.map { classPath[it] ?: error("Failed to find $it on provided classpath.") }.toList() + get() = clazz.interfaces.map { classPath[it] ?: error("Failed to find $it on provided classpath.") } override val fields - get() = clazz.fields.map { MemberDesc(it) }.toList() + get() = clazz.fields.map(::MemberDesc) override val methods - get() = clazz.methods.map { MemberDesc(it) }.toList() + get() = clazz.methods.map(::MemberDesc) override fun getAccess(method: MemberDesc): Int? { return clazz.methods.find { it.name == method.name && it.desc == method.desc }?.access diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt index 74fa9337fd..42d209c184 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt @@ -21,13 +21,13 @@ class ReflectionClassMetadata(private val classPath: ClassPath, private val claz get() = if (clazz.superclass != null) classPath[clazz.superclass.asmName]!! else null override val superInterfaces - get() = clazz.interfaces.map { classPath[it.asmName]!! }.toList() + get() = clazz.interfaces.map { classPath[it.asmName]!! } override val fields - get() = clazz.declaredFields.map { MemberDesc(it.name, Type.getDescriptor(it.type)) }.toList() + get() = clazz.declaredFields.map { MemberDesc(it.name, Type.getDescriptor(it.type)) } override val methods - get() = clazz.declaredMethods.map { MemberDesc(it.name, Type.getMethodDescriptor(it)) }.toList() + get() = clazz.declaredMethods.map { MemberDesc(it.name, Type.getMethodDescriptor(it)) } override fun getAccess(method: MemberDesc): Int? { return clazz.declaredMethods.find { it.name == method.name && Type.getMethodDescriptor(it) == method.desc } diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt index 51afa58f11..a602c8ca8f 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt @@ -51,7 +51,7 @@ data class GlRegistry(val enums: ImmutableSetMultimap, val command val groups = groupsBuilder.asMap().mapValues { entry -> // sort by name length ascending so names with vendor suffixes come last - GlGroup(entry.key, entry.value.sortedBy { enum -> enum.name.length }.toList()) + GlGroup(entry.key, entry.value.sortedBy { enum -> enum.name.length }) } // create parameters and commands diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt b/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt index 62c54cc925..121d0bd498 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt @@ -63,7 +63,7 @@ class ConstSourceInterpreter : Interpreter(Opcodes.ASM7) { insn: AbstractInsnNode, values: List ): ConstSourceValue? { - val args = values.map { it.basicValue }.toList() + val args = values.map(ConstSourceValue::basicValue) val basicValue = basicInterpreter.naryOperation(insn, args) ?: return null return ConstSourceValue.Unknown(basicValue) } diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt index d875b187c3..b7cf89cd05 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt @@ -124,7 +124,7 @@ class IntInterpreter(private val parameters: Array?>?) : Interpreter): IntValue? { - val args = values.map { it.basicValue }.toList() + val args = values.map(IntValue::basicValue) val basicValue = basicInterpreter.naryOperation(insn, args) ?: return null return IntValue.Unknown(basicValue) } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt index b525586649..ebf4b77462 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt @@ -24,8 +24,7 @@ class StaticScramblingTransformer : Transformer() { val dependencies = clinit?.instructions ?.filterIsInstance() ?.filter { it.opcode == Opcodes.GETSTATIC && it.owner != owner.name } - ?.map(::MemberRef) - ?.toSet() ?: emptySet() + ?.mapTo(mutableSetOf(), ::MemberRef) ?: emptySet() } private val fieldSets = mutableMapOf() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt index a2fc79bc06..8974e2a356 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt @@ -78,7 +78,7 @@ class VisibilityTransformer : Transformer() { val hasOverride = overridable && partition.count { classPath[it.owner]!!.methods.contains(MemberDesc(it)) } > 1 val abstract = method && access and Opcodes.ACC_ABSTRACT != 0 val partitionReferences = references[partition] - val partitionOwners = partition.map(MemberRef::owner).toSet() + val partitionOwners = partition.mapTo(mutableSetOf(), MemberRef::owner) // pick the weakest access level based on references in our own code val visibility = when {