Skip to content

Commit b7aac26

Browse files
committed
Revert "dont actually lazy"
This reverts commit 5769d2d.
1 parent 5769d2d commit b7aac26

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/tree/MemoryMappingTree.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,34 @@ class MemoryMappingTree : AbstractMappingTree() {
152152
val nameMap = it.names.toMutableMap()
153153
NameCopyDelegate.fillAllNames(toFill, nameMap)
154154
it.setNames(nameMap)
155+
listOf(
156+
async {
157+
it.fields.resolve()
158+
},
159+
async {
160+
it.methods.resolve()
161+
},
162+
async {
163+
it.wildcards.resolve()
164+
}
165+
).awaitAll()
155166
for (fill in toFill) {
156167
it.acceptInner(
157168
DelegateClassVisitor(it, NameCopyDelegate(fill)),
158169
namespaces,
159170
false
160171
)
172+
listOf(
173+
async {
174+
it.fields.resolve()
175+
},
176+
async {
177+
it.methods.resolve()
178+
},
179+
async {
180+
it.wildcards.resolve()
181+
}
182+
).awaitAll()
161183
}
162184
}
163185
}

src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/tree/node/LazyResolvables.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,22 @@ import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
66
import xyz.wagyourtail.unimined.mapping.visitor.BaseVisitor
77

88
class LazyResolvables<T: BaseVisitor<T>, U>(val mappings: AbstractMappingTree) where U: LazyResolvableEntry<U, T>, U: BaseNode<T, *> {
9+
private val unresolved = mutableListOf<U>()
910
private val resolved = mutableListOf<U>()
1011

1112
val lock = SynchronizedObject()
1213

1314
fun resolve(): List<U> {
14-
return resolved.toList()
15-
}
16-
17-
fun addUnresolved(element: U) {
15+
if (unresolved.isEmpty()) return resolved
1816
synchronized(lock) {
19-
var unresolved: U? = element
20-
while (unresolved != null) {
21-
val u = unresolved
22-
unresolved = null
17+
if (unresolved.isEmpty()) return resolved
18+
while (unresolved.isNotEmpty()) {
19+
val u = unresolved.removeFirst()
2320
var merged = false
2421
for (entry in resolved) {
2522
if (u.merge(entry)) {
2623
merged = true
27-
unresolved = entry
24+
unresolved.add(0, entry)
2825
resolved.remove(entry)
2926
break
3027
}
@@ -33,7 +30,13 @@ class LazyResolvables<T: BaseVisitor<T>, U>(val mappings: AbstractMappingTree) w
3330
resolved.add(u)
3431
}
3532
}
33+
unresolved.clear()
3634
}
35+
return resolved
36+
}
37+
38+
fun addUnresolved(element: U) {
39+
unresolved.add(element)
3740
}
3841

3942
}

0 commit comments

Comments
 (0)