Remove spurious toCollection calls

Signed-off-by: Major <major@emulate.rs>
bzip2
Major 5 years ago
parent 3a29f61d7c
commit 5fa9e9a621
  1. 2
      asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt
  2. 6
      asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt
  3. 6
      asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt
  4. 2
      deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt
  5. 2
      deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt
  6. 2
      deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt
  7. 3
      deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt
  8. 2
      deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt

@ -31,7 +31,7 @@ private fun remap(i: Int, argType: Type, localIndex: Int): Int {
} }
private fun remapAll(indexes: List<Int>, argType: Type, localIndex: Int): MutableList<Int> { private fun remapAll(indexes: List<Int>, argType: Type, localIndex: Int): MutableList<Int> {
return indexes.map { remap(it, argType, localIndex) }.toMutableList() return indexes.mapTo(mutableListOf()) { remap(it, argType, localIndex) }
} }
fun MethodNode.removeArgument(argIndex: Int) { fun MethodNode.removeArgument(argIndex: Int) {

@ -19,13 +19,13 @@ class AsmClassMetadata(
get() = clazz.superName?.let { classPath[it] ?: error("Failed to find $it on provided classpath.") } get() = clazz.superName?.let { classPath[it] ?: error("Failed to find $it on provided classpath.") }
override val superInterfaces 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 override val fields
get() = clazz.fields.map { MemberDesc(it) }.toList() get() = clazz.fields.map(::MemberDesc)
override val methods override val methods
get() = clazz.methods.map { MemberDesc(it) }.toList() get() = clazz.methods.map(::MemberDesc)
override fun getAccess(method: MemberDesc): Int? { override fun getAccess(method: MemberDesc): Int? {
return clazz.methods.find { it.name == method.name && it.desc == method.desc }?.access return clazz.methods.find { it.name == method.name && it.desc == method.desc }?.access

@ -21,13 +21,13 @@ class ReflectionClassMetadata(private val classPath: ClassPath, private val claz
get() = if (clazz.superclass != null) classPath[clazz.superclass.asmName]!! else null get() = if (clazz.superclass != null) classPath[clazz.superclass.asmName]!! else null
override val superInterfaces override val superInterfaces
get() = clazz.interfaces.map { classPath[it.asmName]!! }.toList() get() = clazz.interfaces.map { classPath[it.asmName]!! }
override val fields 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 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? { override fun getAccess(method: MemberDesc): Int? {
return clazz.declaredMethods.find { it.name == method.name && Type.getMethodDescriptor(it) == method.desc } return clazz.declaredMethods.find { it.name == method.name && Type.getMethodDescriptor(it) == method.desc }

@ -51,7 +51,7 @@ data class GlRegistry(val enums: ImmutableSetMultimap<Long, GlEnum>, val command
val groups = groupsBuilder.asMap().mapValues { entry -> val groups = groupsBuilder.asMap().mapValues { entry ->
// sort by name length ascending so names with vendor suffixes come last // 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 // create parameters and commands

@ -63,7 +63,7 @@ class ConstSourceInterpreter : Interpreter<ConstSourceValue>(Opcodes.ASM7) {
insn: AbstractInsnNode, insn: AbstractInsnNode,
values: List<ConstSourceValue> values: List<ConstSourceValue>
): ConstSourceValue? { ): ConstSourceValue? {
val args = values.map { it.basicValue }.toList() val args = values.map(ConstSourceValue::basicValue)
val basicValue = basicInterpreter.naryOperation(insn, args) ?: return null val basicValue = basicInterpreter.naryOperation(insn, args) ?: return null
return ConstSourceValue.Unknown(basicValue) return ConstSourceValue.Unknown(basicValue)
} }

@ -124,7 +124,7 @@ class IntInterpreter(private val parameters: Array<Set<Int>?>?) : Interpreter<In
} }
override fun naryOperation(insn: AbstractInsnNode, values: List<IntValue>): IntValue? { override fun naryOperation(insn: AbstractInsnNode, values: List<IntValue>): IntValue? {
val args = values.map { it.basicValue }.toList() val args = values.map(IntValue::basicValue)
val basicValue = basicInterpreter.naryOperation(insn, args) ?: return null val basicValue = basicInterpreter.naryOperation(insn, args) ?: return null
return IntValue.Unknown(basicValue) return IntValue.Unknown(basicValue)
} }

@ -24,8 +24,7 @@ class StaticScramblingTransformer : Transformer() {
val dependencies = clinit?.instructions val dependencies = clinit?.instructions
?.filterIsInstance<FieldInsnNode>() ?.filterIsInstance<FieldInsnNode>()
?.filter { it.opcode == Opcodes.GETSTATIC && it.owner != owner.name } ?.filter { it.opcode == Opcodes.GETSTATIC && it.owner != owner.name }
?.map(::MemberRef) ?.mapTo(mutableSetOf(), ::MemberRef) ?: emptySet<MemberRef>()
?.toSet() ?: emptySet()
} }
private val fieldSets = mutableMapOf<MemberRef, FieldSet>() private val fieldSets = mutableMapOf<MemberRef, FieldSet>()

@ -78,7 +78,7 @@ class VisibilityTransformer : Transformer() {
val hasOverride = overridable && partition.count { classPath[it.owner]!!.methods.contains(MemberDesc(it)) } > 1 val hasOverride = overridable && partition.count { classPath[it.owner]!!.methods.contains(MemberDesc(it)) } > 1
val abstract = method && access and Opcodes.ACC_ABSTRACT != 0 val abstract = method && access and Opcodes.ACC_ABSTRACT != 0
val partitionReferences = references[partition] 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 // pick the weakest access level based on references in our own code
val visibility = when { val visibility = when {

Loading…
Cancel
Save