优化
This commit is contained in:
@@ -77,6 +77,7 @@ class AnalyzeRule(
|
|||||||
private val regexCache = hashMapOf<String, Regex?>()
|
private val regexCache = hashMapOf<String, Regex?>()
|
||||||
private val scriptCache = hashMapOf<String, CompiledScript>()
|
private val scriptCache = hashMapOf<String, CompiledScript>()
|
||||||
private var topScopeRef: WeakReference<Scriptable>? = null
|
private var topScopeRef: WeakReference<Scriptable>? = null
|
||||||
|
private var evalJSCallCount = 0
|
||||||
|
|
||||||
private var coroutineContext: CoroutineContext = EmptyCoroutineContext
|
private var coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||||
|
|
||||||
@@ -781,7 +782,9 @@ class AnalyzeRule(
|
|||||||
val topScope = source?.getShareScope(coroutineContext) ?: topScopeRef?.get()
|
val topScope = source?.getShareScope(coroutineContext) ?: topScopeRef?.get()
|
||||||
val scope = if (topScope == null) {
|
val scope = if (topScope == null) {
|
||||||
RhinoScriptEngine.getRuntimeScope(bindings).apply {
|
RhinoScriptEngine.getRuntimeScope(bindings).apply {
|
||||||
topScopeRef = WeakReference(prototype)
|
if (evalJSCallCount++ > 16) {
|
||||||
|
topScopeRef = WeakReference(prototype)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bindings.apply {
|
bindings.apply {
|
||||||
|
|||||||
Reference in New Issue
Block a user