[RouteOpt]优化引导线代码逻辑

This commit is contained in:
renwj
2022-08-03 16:17:40 +08:00
parent 95d557ea00
commit fb81bd01b4

View File

@@ -40,6 +40,7 @@ class ColorfulStrategy(private val colors: List<Int> = emptyList(), var isLightO
object RouteStrategy {
@Volatile
private var isEnable = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) && !AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
private var strategy: Strategy? = null
@@ -65,6 +66,9 @@ object RouteStrategy {
}
fun start() {
if (sorted.isEmpty()) {
fill()
}
strategy = null
index = 0
startColor = Int.MAX_VALUE
@@ -89,10 +93,7 @@ object RouteStrategy {
return
}
if (sorted.isEmpty()) {
fill()
}
if (sorted.isEmpty()) {
throw AssertionError("sorted map must not be null.")
return
}
if (acc < 0) {
hasLessThan0 = true
@@ -122,6 +123,9 @@ object RouteStrategy {
}
fun remove(acc: Double): List<Int> {
if (!isEnable) {
return emptyList()
}
if (sorted.isEmpty()) {
throw AssertionError("sorted map must not be null.")
}