another ~0.03s less :3

This commit is contained in:
moehreag 2024-05-28 12:26:55 +02:00
parent 1dcd0c8c05
commit dd8b87a1cf

View file

@ -103,7 +103,7 @@ class AWProcessor {
classNames.parallelStream().forEach(name -> { classNames.parallelStream().forEach(name -> {
try { try {
processFile(out.getPath("/" + name + ".class"), classMap, fields, methods, mutations); processFile(name, out.getPath("/" + name + ".class"), classMap, fields, methods, mutations);
} catch (IOException e) { } catch (IOException e) {
throw new Error(e); throw new Error(e);
} }
@ -113,9 +113,7 @@ class AWProcessor {
LOGGER.info(String.format("Applied AccessWideners in %.2fs", (System.currentTimeMillis() - startTime) / 1000f)); LOGGER.info(String.format("Applied AccessWideners in %.2fs", (System.currentTimeMillis() - startTime) / 1000f));
} }
private static void processFile(Path file, Map<String, Entry> classMap, Map<String, Map<String, Entry>> fields, Map<String, Map<String, Entry>> methods, Map<String, Map<String, Entry>> mutations) throws IOException { private static void processFile(String className, Path file, Map<String, Entry> classMap, Map<String, Map<String, Entry>> fields, Map<String, Map<String, Entry>> methods, Map<String, Map<String, Entry>> mutations) throws IOException {
var className = file.toString().substring(1, file.toString().length() - 6);
if (file.getFileName().toString().endsWith(".class") && (classMap.containsKey(className) || fields.containsKey(className) || methods.containsKey(className) || mutations.containsKey(className))) {
ClassReader reader = new ClassReader(Files.newInputStream(file)); ClassReader reader = new ClassReader(Files.newInputStream(file));
ClassWriter writer = new ClassWriter(0); ClassWriter writer = new ClassWriter(0);
ClassVisitor mapper = new ClassVisitor(Opcodes.ASM9, writer) { ClassVisitor mapper = new ClassVisitor(Opcodes.ASM9, writer) {
@ -170,7 +168,6 @@ class AWProcessor {
Files.write(file, writer.toByteArray()); Files.write(file, writer.toByteArray());
} }
}
private record Entry(AccessType type, String targetType, String className, String name, String descriptor) { private record Entry(AccessType type, String targetType, String className, String name, String descriptor) {