Zyle Moore
06/14/2025, 4:03 AMdelay(1)
after each chunked(10000)
right now. Without it, there is no delay between chunks, and the page hangs (no render/update) until it's gone through every chunk. There's about 4 million elements that it reads, and takes about 20 seconds (16 seconds without delay). I'm performing this iteration in a useEffect
. Is there something else I should be doing?
useEffect(byteString, setElementMarkers, setLastElementMarkerRead) {
val elementMarkerSequence: Sequence<PluginElementMarker> =
PluginFormat.decodeMarkerSequenceFromByteString(byteString)
val tokenList: MutableList<PluginElementMarker> = mutableListOf()
val toListTime = measureTime {
elementMarkerSequence
.chunked(10000)
.forEach { chunk ->
tokenList.addAll(chunk)
setLastElementMarkerRead(chunk.last())
delay(1)
}
}
println("toList time $toListTime ${tokenList.size}")
setElementMarkers(tokenList)
}
// ...
progress {
max = byteString.size.toDouble()
value = lastElementMarkerRead?.skip ?: 0
}
turansky
06/15/2025, 11:56 AMZyle Moore
06/16/2025, 2:10 AMBinaryFormat
for reading Skyrim mod files. A Type-Length-Value format. I noticed that there's actually useEffectOnce and useEffectOnceWithCleanup, but when making a job and cleanup function, it behaves like it does without a delay (hangs until complete)turansky
06/16/2025, 12:05 PMturansky
06/16/2025, 1:26 PMturansky
06/16/2025, 1:27 PM