Replace ByteStreams with Kotlin extension method

bzip2
Graham 5 years ago
parent 06b8af41e2
commit 5038d1d671
  1. 3
      bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt
  2. 3
      decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt
  3. 3
      deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt

@ -12,7 +12,6 @@ import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.FieldInsnNode
import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.LdcInsnNode
import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.MethodNode
import kotlin.streams.asSequence
class BufferSizeTransformer : Transformer() { class BufferSizeTransformer : Transformer() {
private var buffer: MemberRef? = null private var buffer: MemberRef? = null
@ -63,7 +62,7 @@ class BufferSizeTransformer : Transformer() {
private val NEW_BUFFER_MATCHER = InsnMatcher.compile("NEW DUP (SIPUSH | LDC) INVOKESPECIAL PUTSTATIC") private val NEW_BUFFER_MATCHER = InsnMatcher.compile("NEW DUP (SIPUSH | LDC) INVOKESPECIAL PUTSTATIC")
private fun findBuffer(method: MethodNode): MemberRef? { private fun findBuffer(method: MethodNode): MemberRef? {
return GPP1_POS_MATCHER.match(method).asSequence().filter { return GPP1_POS_MATCHER.match(method).filter {
val ldc = it[0] as LdcInsnNode val ldc = it[0] as LdcInsnNode
ldc.cst == "gpp1 pos:" ldc.cst == "gpp1 pos:"
}.map { }.map {

@ -1,6 +1,5 @@
package dev.openrs2.decompiler package dev.openrs2.decompiler
import com.google.common.io.ByteStreams
import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider
import org.jetbrains.java.decompiler.main.extern.IResultSaver import org.jetbrains.java.decompiler.main.extern.IResultSaver
import java.io.Closeable import java.io.Closeable
@ -22,7 +21,7 @@ class DecompilerIo(private val destination: (String) -> Path) : IBytecodeProvide
} }
jar.getInputStream(jar.getJarEntry(internalPath)).use { jar.getInputStream(jar.getJarEntry(internalPath)).use {
return ByteStreams.toByteArray(it) return it.readBytes()
} }
} }

@ -13,7 +13,6 @@ import org.objectweb.asm.tree.InsnNode
import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodInsnNode
import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.MethodNode
import org.objectweb.asm.tree.VarInsnNode import org.objectweb.asm.tree.VarInsnNode
import kotlin.streams.asSequence
class BitwiseOpTransformer : Transformer() { class BitwiseOpTransformer : Transformer() {
private val methodOps = mutableMapOf<MemberRef, Int>() private val methodOps = mutableMapOf<MemberRef, Int>()
@ -38,7 +37,7 @@ class BitwiseOpTransformer : Transformer() {
continue continue
} }
val match = BITWISE_OP_MATCHER.match(method).asSequence().firstOrNull() ?: continue val match = BITWISE_OP_MATCHER.match(method).firstOrNull() ?: continue
val iload0 = match[0] as VarInsnNode val iload0 = match[0] as VarInsnNode
val iload1 = match[1] as VarInsnNode val iload1 = match[1] as VarInsnNode

Loading…
Cancel
Save