From 5256f00ee0f2b9b3d40fcad4da6f05d96f1fc18d Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 24 Apr 2020 23:27:14 +0100 Subject: [PATCH] Make libraryClasses return Sequence instead of List Signed-off-by: Graham --- .../main/java/dev/openrs2/asm/classpath/ClassPath.kt | 12 ++---------- .../java/dev/openrs2/deob/remap/TypedRemapper.kt | 6 +++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt index a94a38deee..2cb82fa18a 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt @@ -28,16 +28,8 @@ class ClassPath( */ val originalPcs = mutableMapOf() - val libraryClasses: List - get() { - val classes = mutableListOf() - for (library in libraries) { - for (clazz in library) { - classes.add(get(clazz.name)!!) - } - } - return classes - } + val libraryClasses: Sequence + get() = libraries.asSequence().flatten().map { get(it.name)!! } private inline fun computeIfAbsent(name: String, f: (String) -> ClassMetadata?): ClassMetadata? { if (cache.containsKey(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 33932a7fd0..b6a7041357 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt @@ -56,7 +56,7 @@ class TypedRemapper private constructor( val inheritedFieldSets = classPath.createInheritedFieldSets() val inheritedMethodSets = classPath.createInheritedMethodSets() - val classes = createClassMapping(classPath.libraryClasses) + val classes = createClassMapping(classPath) val fields = createFieldMapping(classPath, inheritedFieldSets, classes) val methods = createMethodMapping(classPath, inheritedMethodSets) @@ -95,10 +95,10 @@ class TypedRemapper private constructor( return prefix + separator + prefixes.merge(prefix, 1, Integer::sum) } - private fun createClassMapping(classes: List): Map { + private fun createClassMapping(classPath: ClassPath): Map { val mapping = mutableMapOf() val prefixes = mutableMapOf() - for (clazz in classes) { + for (clazz in classPath.libraryClasses) { populateClassMapping(mapping, prefixes, clazz) } return mapping