优化:重新渲染时清空节点池

This commit is contained in:
wanglin2 2023-04-05 21:22:39 +08:00
parent 6b15e469a2
commit d7b1c4e4fe
2 changed files with 7 additions and 1 deletions

View File

@ -257,6 +257,7 @@ class Render {
// 重新渲染需要清除激活状态
if (this.reRender) {
this.clearActive()
this.layout.clearNodePool()
}
// 计算布局
this.layout.doLayout(root => {

View File

@ -43,10 +43,15 @@ class Base {
this.nodePool[uid] = node
// 如果总缓存数量达到1000直接清空
if (Object.keys(this.nodePool).length > 1000) {
this.nodePool = {}
this.clearNodePool()
}
}
// 清空节点存储池
clearNodePool() {
this.nodePool = {}
}
// 检查当前来源是否需要重新计算节点大小
checkIsNeedResizeSources() {
return [CONSTANTS.CHANGE_THEME, CONSTANTS.TRANSFORM_TO_NORMAL_NODE].includes(this.renderer.renderSource)