perf: cache vid

This commit is contained in:
lisonge 2024-03-19 11:12:53 +08:00
parent 3a8fa8583d
commit 8169624e39

View File

@ -255,13 +255,29 @@ fun createCacheTransform(): CacheTransform {
}
}
}
var vidCacheNode: AccessibilityNodeInfo? = null
var vidCacheValue: CharSequence? = null
val transform = Transform(
getAttr = { node, name ->
if (name == "index") {
node.getIndexX()
when (name) {
"vid" -> {
if (node === vidCacheNode) {
vidCacheValue
} else {
vidCacheNode = node
vidCacheValue = node.getVid()
vidCacheValue
}
}
"index" -> {
node.getIndexX()
}
else -> {
getAttr(node, name)
}
}
},
getName = { node -> node.className },
getChildren = getChildrenCache,