Skip to content

Commit

Permalink
improve speed after profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Nov 20, 2023
1 parent d98aed7 commit 78a065d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
18 changes: 0 additions & 18 deletions src/api/kotlin/xyz/wagyourtail/unimined/api/runs/RunConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,6 @@ data class RunConfig(
var disabled : Boolean = false,
) {

fun copy(): RunConfig {
return RunConfig(
project,
javaVersion,
name,
taskName,
description,
launchClasspath,
mainClass,
args.toMutableList(),
jvmArgs.toMutableList(),
workingDir,
env.toMutableMap(),
runFirst.toMutableList(),
disabled
)
}

fun createIdeaRunConfig() {
val file = project.rootDir.resolve(".idea")
.resolve("runConfigurations")
Expand Down
24 changes: 10 additions & 14 deletions src/api/kotlin/xyz/wagyourtail/unimined/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package xyz.wagyourtail.unimined.util

import org.apache.commons.compress.archivers.zip.ZipFile
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.Dependency
Expand Down Expand Up @@ -296,23 +297,18 @@ fun Path.forEachInZip(action: (String, InputStream) -> Unit) {
}

fun <T> Path.readZipInputStreamFor(path: String, throwIfMissing: Boolean = true, action: (InputStream) -> T): T {
ZipInputStream(inputStream()).use { stream ->
var entry = stream.nextEntry
while (entry != null) {
if (entry.isDirectory) {
entry = stream.nextEntry
continue
}
if (entry.name == path) {
return action(stream)
Files.newByteChannel(this).use {
ZipFile(it).use { zip ->
val entry = zip.getEntry(path)
if (entry != null) {
return zip.getInputStream(entry).use(action)
} else {
if (throwIfMissing) {
throw IllegalArgumentException("Missing file $path in $this")
}
}
entry = stream.nextEntry
}
}
if (throwIfMissing) {
throw IllegalArgumentException("Missing file $path in $this")
}
@Suppress("UNCHECKED_CAST")
return null as T
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ abstract class PerInputTagExtension<T : PerInputTagExtension.InputTagExtension>
return inputTagExtensions[tag]!!.readInput(remapper, *input)
}

fun readClassPath(remapper: TinyRemapper, vararg classpath: Path): CompletableFuture<Void> {
remapper.readClassPath(*classpath)
return CompletableFuture.completedFuture(null)
fun readClassPath(remapper: TinyRemapper, vararg classpath: Path): CompletableFuture<*> {
return remapper.readClassPathAsync(*classpath)
// return CompletableFuture.completedFuture(null)
}

fun <T, U> Iterable<T>.reduce(identity: U, reducer: T.(U) -> U): U {
Expand Down

0 comments on commit 78a065d

Please sign in to comment.