fix(scripting): optimization level

This commit is contained in:
rhunk
2024-04-30 01:00:15 +02:00
parent 631c044500
commit 9341f5ee7d
2 changed files with 4 additions and 1 deletions

View File

@@ -183,7 +183,9 @@ class JSModule(
else -> moduleBindings[bindingName]?.getObject()
}
}
}
contextScope(shouldOptimize = true) {
evaluateString(moduleObject, content, moduleInfo.name, 1, null)
}
}

View File

@@ -10,9 +10,10 @@ import java.io.File
private val rhinoAndroidHelper = RhinoAndroidHelper(null as File?)
fun contextScope(f: Context.() -> Any?): Any? {
fun contextScope(shouldOptimize: Boolean = false, f: Context.() -> Any?): Any? {
val context = rhinoAndroidHelper.enterContext().apply {
languageVersion = Context.VERSION_ES6
optimizationLevel = if (!shouldOptimize) -1 else 0
}
try {
return context.f().let {