Unused params test, this is very slow.
This commit is contained in:
@@ -153,8 +153,12 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
|
||||
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
|
||||
if (otherClass == null)
|
||||
return null; // not our class
|
||||
|
||||
net.runelite.asm.Method m = otherClass.findMethod(method.getNameAndType());
|
||||
if (m == null)
|
||||
return null;
|
||||
|
||||
return Renamer.getVirutalMethods(otherClass.findMethod(method.getNameAndType()));
|
||||
return Renamer.getVirutalMethods(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -151,9 +151,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
||||
|
||||
net.runelite.asm.Method m = otherClass.findMethodDeep(method.getNameAndType());
|
||||
if (m == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Renamer.getVirutalMethods(m);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public class UnusedParameters implements Deobfuscator
|
||||
method.arguments.remove(paramIndex);
|
||||
}
|
||||
|
||||
private int[] checkParametersOnce(Execution execution, ClassGroup group)
|
||||
private int checkParametersOnce(Execution execution, ClassGroup group)
|
||||
{
|
||||
// removing parameters shifts the others around which is annoying.
|
||||
// if more than one is unused, we'll just remove the one
|
||||
@@ -263,14 +263,15 @@ public class UnusedParameters implements Deobfuscator
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new int[] { count };
|
||||
return count;
|
||||
}
|
||||
|
||||
private int count;
|
||||
|
||||
@Override
|
||||
public void run(ClassGroup group)
|
||||
{
|
||||
int count = 0;
|
||||
int[] i;
|
||||
int i;
|
||||
do
|
||||
{
|
||||
group.buildClassGraph();
|
||||
@@ -281,10 +282,15 @@ public class UnusedParameters implements Deobfuscator
|
||||
|
||||
i = checkParametersOnce(execution, group);
|
||||
|
||||
count += i[0];
|
||||
count += i;
|
||||
}
|
||||
while (i[0] > 0);
|
||||
while (i > 0);
|
||||
|
||||
System.out.println("Removed " + count + " unused parameters");
|
||||
}
|
||||
|
||||
public int getCount()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.runelite.deob.deobfuscators;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import net.runelite.asm.ClassGroup;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class UnusedParametersTest
|
||||
{
|
||||
private static final File GAMEPACK = new File(RenameUniqueTest.class.getResource("/gamepack_v16.jar").getFile());
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private ClassGroup group;
|
||||
|
||||
@Before
|
||||
public void before() throws IOException
|
||||
{
|
||||
group = JarUtil.loadJar(GAMEPACK);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws IOException
|
||||
{
|
||||
JarUtil.saveJar(group, folder.newFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun()
|
||||
{
|
||||
UnusedParameters cp = new UnusedParameters();
|
||||
cp.run(group);
|
||||
Assert.assertEquals(357, cp.getCount());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user