Make libraryClasses return Sequence instead of List

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 5 years ago
parent 49a90c1cf5
commit 5256f00ee0
  1. 12
      asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt
  2. 6
      deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt

@ -28,16 +28,8 @@ class ClassPath(
*/ */
val originalPcs = mutableMapOf<AbstractInsnNode, Int>() val originalPcs = mutableMapOf<AbstractInsnNode, Int>()
val libraryClasses: List<ClassMetadata> val libraryClasses: Sequence<ClassMetadata>
get() { get() = libraries.asSequence().flatten().map { get(it.name)!! }
val classes = mutableListOf<ClassMetadata>()
for (library in libraries) {
for (clazz in library) {
classes.add(get(clazz.name)!!)
}
}
return classes
}
private inline fun computeIfAbsent(name: String, f: (String) -> ClassMetadata?): ClassMetadata? { private inline fun computeIfAbsent(name: String, f: (String) -> ClassMetadata?): ClassMetadata? {
if (cache.containsKey(name)) { if (cache.containsKey(name)) {

@ -56,7 +56,7 @@ class TypedRemapper private constructor(
val inheritedFieldSets = classPath.createInheritedFieldSets() val inheritedFieldSets = classPath.createInheritedFieldSets()
val inheritedMethodSets = classPath.createInheritedMethodSets() val inheritedMethodSets = classPath.createInheritedMethodSets()
val classes = createClassMapping(classPath.libraryClasses) val classes = createClassMapping(classPath)
val fields = createFieldMapping(classPath, inheritedFieldSets, classes) val fields = createFieldMapping(classPath, inheritedFieldSets, classes)
val methods = createMethodMapping(classPath, inheritedMethodSets) val methods = createMethodMapping(classPath, inheritedMethodSets)
@ -95,10 +95,10 @@ class TypedRemapper private constructor(
return prefix + separator + prefixes.merge(prefix, 1, Integer::sum) return prefix + separator + prefixes.merge(prefix, 1, Integer::sum)
} }
private fun createClassMapping(classes: List<ClassMetadata>): Map<String, String> { private fun createClassMapping(classPath: ClassPath): Map<String, String> {
val mapping = mutableMapOf<String, String>() val mapping = mutableMapOf<String, String>()
val prefixes = mutableMapOf<String, Int>() val prefixes = mutableMapOf<String, Int>()
for (clazz in classes) { for (clazz in classPath.libraryClasses) {
populateClassMapping(mapping, prefixes, clazz) populateClassMapping(mapping, prefixes, clazz)
} }
return mapping return mapping

Loading…
Cancel
Save