diff --git a/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt index bcc65f8cb0..566fb4b58c 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt @@ -250,9 +250,9 @@ val AbstractInsnNode.intConstant: Int? } val AbstractInsnNode.pure: Boolean - get() = when { - PURE_OPCODES.contains(opcode) -> true - IMPURE_OPCODES.contains(opcode) -> false + get() = when (opcode) { + in PURE_OPCODES -> true + in IMPURE_OPCODES -> false else -> throw IllegalArgumentException() } diff --git a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt index ef5f10469f..6fad19e13e 100644 --- a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt @@ -79,14 +79,14 @@ fun MethodNode.removeArgument(argIndex: Int) { } if (visibleLocalVariableAnnotations != null) { - visibleLocalVariableAnnotations.removeIf { it.index.contains(localIndex) } + visibleLocalVariableAnnotations.removeIf { localIndex in it.index } for (annotation in visibleLocalVariableAnnotations) { annotation.index = remapAll(annotation.index, argType, localIndex) } } if (invisibleLocalVariableAnnotations != null) { - invisibleLocalVariableAnnotations.removeIf { it.index.contains(localIndex) } + invisibleLocalVariableAnnotations.removeIf { localIndex in it.index } for (annotation in invisibleLocalVariableAnnotations) { annotation.index = remapAll(annotation.index, argType, localIndex) } @@ -133,7 +133,7 @@ fun MethodNode.removeDeadCode(owner: String) { } } - changed = changed or tryCatchBlocks.removeIf { deadLabels.contains(it.start) && deadLabels.contains(it.end) } + changed = changed or tryCatchBlocks.removeIf { it.start in deadLabels && it.end in deadLabels } } while (changed) } diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt index 2116debac3..f593af7f4b 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt @@ -16,7 +16,7 @@ abstract class ClassMetadata { fun isOverride(method: MemberDesc): Boolean { val superClass = this.superClass if (superClass != null) { - if (superClass.methods.contains(method)) { + if (method in superClass.methods) { return true } @@ -26,7 +26,7 @@ abstract class ClassMetadata { } for (superInterface in superInterfaces) { - if (superInterface.methods.contains(method)) { + if (method in superInterface.methods) { return true } diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt index d3104603a2..388ad71682 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt @@ -15,7 +15,7 @@ class BitMaskTransformer : Transformer() { val left = expr.left val shamtExpr = expr.right - if (!SHIFT_OPS.contains(shiftOp) || !left.isBinaryExpr || !shamtExpr.isIntegerLiteralExpr) { + if (shiftOp !in SHIFT_OPS || !left.isBinaryExpr || !shamtExpr.isIntegerLiteralExpr) { return@walk } @@ -24,7 +24,7 @@ class BitMaskTransformer : Transformer() { val argExpr = bitwiseExpr.left var maskExpr = bitwiseExpr.right - if (!BITWISE_OPS.contains(bitwiseOp) || !maskExpr.isIntegerOrLongLiteral()) { + if (bitwiseOp !in BITWISE_OPS || !maskExpr.isIntegerOrLongLiteral()) { return@walk } diff --git a/deob/src/main/java/dev/openrs2/deob/SignedClassUtils.kt b/deob/src/main/java/dev/openrs2/deob/SignedClassUtils.kt index 6f692d1c3c..a38eeb938c 100644 --- a/deob/src/main/java/dev/openrs2/deob/SignedClassUtils.kt +++ b/deob/src/main/java/dev/openrs2/deob/SignedClassUtils.kt @@ -82,7 +82,7 @@ object SignedClassUtils { } val name = type.className - if (loader.contains(name) && !signedClasses.contains(name)) { + if (name in loader && name !in signedClasses) { dependencies.add(name) } } diff --git a/deob/src/main/java/dev/openrs2/deob/remap/PrefixRemapper.kt b/deob/src/main/java/dev/openrs2/deob/remap/PrefixRemapper.kt index 41c4c35a6a..c7c3e0f2a0 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/PrefixRemapper.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/PrefixRemapper.kt @@ -9,7 +9,7 @@ object PrefixRemapper { val mapping = mutableMapOf() for (clazz in library) { - if (TypedRemapper.EXCLUDED_CLASSES.contains(clazz.name)) { + if (clazz.name in TypedRemapper.EXCLUDED_CLASSES) { mapping[clazz.name] = clazz.name } else { mapping[clazz.name] = prefix + clazz.name diff --git a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt index eea713031f..4bb7aa1b1e 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt @@ -103,7 +103,7 @@ class TypedRemapper private constructor( clazz: ClassMetadata ): String { val name = clazz.name - if (mapping.containsKey(name) || EXCLUDED_CLASSES.contains(name) || clazz.dependency) { + if (mapping.containsKey(name) || name in EXCLUDED_CLASSES || clazz.dependency) { return mapping.getOrDefault(name, name) } @@ -138,7 +138,7 @@ class TypedRemapper private constructor( for ((owner, name) in partition) { val clazz = classPath[owner] - if (EXCLUDED_FIELDS.contains(name)) { + if (name in EXCLUDED_FIELDS) { skip = true break } @@ -188,7 +188,7 @@ class TypedRemapper private constructor( for (method in partition) { val clazz = classPath[method.owner] - if (EXCLUDED_METHODS.contains(method.name)) { + if (method.name in EXCLUDED_METHODS) { return true } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt index adf0e9e756..4ff0e26c54 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt @@ -29,7 +29,7 @@ class BitShiftTransformer : Transformer() { val bits = push.intConstant!! val opcode = match[1].opcode - val mask = if (LONG_SHIFTS.contains(opcode)) 63 else 31 + val mask = if (opcode in LONG_SHIFTS) 63 else 31 val simplifiedBits = bits and mask diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt index a90f8908c3..6dc1d826b6 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt @@ -94,7 +94,7 @@ class CounterTransformer : Transformer() { ): Boolean { for (match in RESET_PATTERN.match(method)) { val putstatic = match[1] as FieldInsnNode - if (counters.contains(MemberRef(putstatic))) { + if (MemberRef(putstatic) in counters) { match.forEach(method.instructions::remove) } } @@ -102,7 +102,7 @@ class CounterTransformer : Transformer() { for (match in INCREMENT_PATTERN.match(method)) { val getstatic = MemberRef(match[0] as FieldInsnNode) val putstatic = MemberRef(match[3] as FieldInsnNode) - if (getstatic == putstatic && counters.contains(putstatic)) { + if (getstatic == putstatic && putstatic in counters) { match.forEach(method.instructions::remove) } } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt index 054ffd8bdd..528f11f0eb 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt @@ -311,7 +311,7 @@ class DummyArgTransformer : Transformer() { } for ((insn, value) in constInsns) { - if (!method.instructions.contains(insn)) { + if (insn !in method.instructions) { continue } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt index 04b0c4e11b..672cdd81dd 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt @@ -54,7 +54,7 @@ class OpaquePredicateTransformer : Transformer() { } private fun isFlowObstructor(insn: FieldInsnNode): Boolean { - return flowObstructors.contains(MemberRef(insn)) + return MemberRef(insn) in flowObstructors } private fun isOpaquePredicate(method: MethodNode, match: List): Boolean { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt index 8d4d6183d9..aadde4708b 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt @@ -122,7 +122,7 @@ class UnusedArgTransformer : Transformer() { val newArgTypes = mutableListOf() for ((j, argType) in argTypes.withIndex()) { - if (INT_SORTS.contains(argType.sort) && !retainedArgs.contains(ArgRef(partition, j))) { + if (argType.sort in INT_SORTS && ArgRef(partition, j) !in retainedArgs) { val value = frame.getStack(stackSize - argTypes.size + j) as ConstSourceValue.Single deadInsns.add(value.source) } else { @@ -152,7 +152,7 @@ class UnusedArgTransformer : Transformer() { val argTypes = Type.getType(method.desc).argumentTypes for ((i, argType) in argTypes.withIndex().reversed()) { - if (INT_SORTS.contains(argType.sort) && !retainedArgs.contains(ArgRef(partition, i))) { + if (argType.sort in INT_SORTS && ArgRef(partition, i) !in retainedArgs) { method.removeArgument(i) deletedArgs++ }